Under most circumstances the default copy constructor provided by the compiler (member-wise copy) is sufficient. The cases where it is not sufficient are:
1) You have a very old compiler which provides a bit-wise copy instead;
2) Your class contains pointer members, and you need to perform a deep copy.
If you need to write a copy constructor, the general form is:
1 2 3 4 5
class Foo {
Foo( const Foo& f ) :
mem1( f.mem1 ), mem2( f.mem2 ) /* etc */
{}
};
where mem1 and mem2 are data members of Foo, which can be const
members, non-const members, const references or non-const references.