Kittu said:
Why should we use the copy constructor.Which is the best way to
initialize object using copy constructor or using assignment operator
and why?
We should _implement_ a copy constructor if we care how the object is
constructed from another object of the same type. The reason (for the
'why' question) is that the language rules dictate that copies are made
in certain situations, and if you don't provide the copy c-tor, the
compiler will attempt to create one for you. The same with the copy
assignment operator.
The most common situation in which a copy c-tor and a copy assignment
operator is needed is described in "The Rule Of Three". Look it up.
Victor