As we know that both copy constructors and overloading = opeartor copies one object to another then whats the difference between copy constructor and overloading = operator. There must be some difference ... right?
the differeces are :-
Copy constructor is invoked when objects are initialized ;) for ex.
1.when a new object is constructed and initialized with the existing object.
--- CLASS a = b; and CLASS a(b); //b is already existing object.
2.when objects are passed as arguement to the function then copy constructor is invoked
3.when a function returns by value then copy constructor is invoekd.
Overloading = opertator is called when objects are copied or during assignment :) .
ex. CLASS a; CLASS b; a=b;
I think this will help you.