![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
What is the other way of calling the overloaded assignment operator?in the code below.. what is the other way of calling the overloaded assignment operator? descriped in the commnets below. Also, this function returns a reference "&", this mean the copy constructor is called, correct?
CPP / C++ / C Code:
Thanks Daniel |
|||
|
#2
|
||||
|
||||
Re: Another Question?Quote:
Quote:
Member functions (not static member functions...) require an object to call the member function. While the following: Quote:
Code:
Quote:
|
|
#3
|
|||
|
|||
Re: What is the other way of calling the overloaded assignment operator?ok thanks OCICAT, yeah the thing is i test so much stuff that some times its just easier to post a question and go back to it later, the responses on the forum are so fast that I got spoiled. I love this place. Yeah i know -> is better then (*this).operator but im just a begginer so I want to make sure I know all the possiblilites, other people have different style, i want to understand everything
Thanks AGain, this forum is the shittt!! |
|
#4
|
|||
|
|||
Re: What is the other way of calling the overloaded assignment operator?Just wanted to add, for those that may be learning like me that:
Quote:
the copy constructor is call when returning BY VALUE, passing BY VALUE to a function as a paramater and initialization of an object using the assigment '=' operator to another object as OSICAT pointed out. Thanks Daniel |
|
#5
|
|||
|
|||
Re: What is the other way of calling the overloaded assignment operator?in your code above i see you return an object on the free store (heap) "By Reference" or easy to say an "Alias" of Object on the free store (heap).
return *this; // right ? its mean you dereference the this pointer of current object its pointed to, an the result is the object on the free store (heap), not a copy constructor or constructor anymore. |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Please, This is Difficult question try for me! | bcompt143 | C++ Forum | 4 | 24-Aug-2008 10:14 |
| Question about locking surfaces to directly access pixels, SDL. | george89 | C++ Forum | 0 | 18-Jun-2006 22:16 |
| Question re "Similar Pages" on Google | jep | Search Engine Optimization Forum | 0 | 17-May-2005 10:52 |
| question of practice | magiccreative | C++ Forum | 1 | 06-Feb-2004 08:17 |
| Motherboard and CPU Question | pcxgamer | Computer Hardware Forum | 2 | 29-Oct-2002 07:15 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The