Operator overloading for pointer to objects .

Discussion in 'C++' started by vivekian, Dec 11, 2005.

  1. vivekian

    vivekian Guest

    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
    vivekian, Dec 11, 2005
    #1
    1. Advertising

  2. 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.
    Neelesh Bodas, Dec 11, 2005
    #2
    1. Advertising

  3. vivekian

    vivekian Guest

    Thanks
    vivekian, Dec 11, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Smith
    Replies:
    2
    Views:
    417
    Ivan Vecerina
    Oct 6, 2004
  2. Replies:
    11
    Views:
    726
    James Kanze
    May 16, 2007
  3. hurcan solter
    Replies:
    3
    Views:
    723
    Cholo Lennon
    Aug 29, 2007
  4. Replies:
    11
    Views:
    555
  5. Replies:
    2
    Views:
    306
Loading...

Share This Page