Turn from: http://blog.csdn.net/feixiaoxing/article/details/6772964
Copy constructors and copy functions are two of the more important functions within a class. What is the difference between the two? In fact, it is also very simple, for example, to add the definition of a class:
View Plain class Apple {public:apple () {printf ("Apple ()!\n");} Apple (apple& a) {printf ("Copy apple ()!\n");} apple& operator= (apple& a) {printf ("= apple () \ n"); return *this;} ~apple () {printf ("~apple ()!\n");} void print () const {return;} };
So what are the functions that we call when we call them in the following function?
View Plain void process () { apple a, c; apple b =a; c = b; } In fact, the results of the compilation is such that we can take a look at it and try to read it ourselves. If you don't understand it at once, you can read it more times.
View Plain 70: apple a, c; 0040127D lea ecx,[ebp-10h] 00401280 call @ILT +70 (apple::apple) (0040104b) 00401285   MOV         DWORD PTR [EBP-4] ,0 0040128c lea ecx,[ebp-14h] 0040128f call @ILT +70 (apple::apple ) (0040104b)