Copy constructor allows creation of new object from an existing one.
Hence in the following cases copy contr wud be called:
1)Obj o1(o);
2)Obj o2 = o;
(o is also an oject of Obj)
But the statement 2 can also be realised by overloading =operator.
So what will happen if i have both declared:copy constr & =operator.And what is the difference??
If you do not define an assignment operator, the compiler will generate a default one. The default one does a member by member copy, which is ok for classes that contain only POD member data. One red flag that the compiler-generated one is not adequate is if the class contains one or more pointers. The same goes for the copy constructor.