Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Operator overloading for pointer to objects .

Reply
Thread Tools

Operator overloading for pointer to objects .

 
 
vivekian
Guest
Posts: n/a
 
      12-11-2005
Have a pointer to an object of class type task

task * A ;

Now this object takes operator overloading like

A<<2 ;

which assigns the number 2 to one of the members of the object A.

Is there a way to do this with the pointer to the object ?

Thanks ,
vivekian

 
Reply With Quote
 
 
 
 
Neelesh Bodas
Guest
Posts: n/a
 
      12-11-2005
vivekian wrote:
> Have a pointer to an object of class type task
>
> task * A ;
>
> Now this object takes operator overloading like


it doesnot make sense to say "an object takes operator overloading".
Perhaps you mean that operator<< is overloaded for class task.
>
> A<<2 ;
>
> which assigns the number 2 to one of the members of the object A.
>
> Is there a way to do this with the pointer to the object ?
>


While oveloading any operator, atleast one argument must be of user
defined type. So operator<<(task*, int) is an incorrect overloading.
Hence A<<2 will also not work

Hope that helps.

 
Reply With Quote
 
 
 
 
vivekian
Guest
Posts: n/a
 
      12-11-2005
Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
overloading operator->*() and operator->() gob00st@googlemail.com C++ 2 02-21-2009 04:26 AM
overloading operator->*() and operator->() gob00st@googlemail.com C++ 11 02-20-2009 08:52 PM
user defined conversion operator or operator overloading? hurcan solter C++ 3 08-29-2007 07:39 PM
Why is overloading operator. (member operator) forbidden? dascandy@gmail.com C++ 11 05-16-2007 07:54 PM
Operator overloading on "default" operator John Smith C++ 2 10-06-2004 10:22 AM



Advertisments