Code:
class Parent {
int i;
public:
Parent(int ii) : i(ii) {
cout << "Parent(int ii)\n";
}
Parent(const Parent& b) : i(b.i) {
cout << "Parent(const Parent&)\n";
}
Parent() : i(0) { cout << "Parent()\n"; }
friend ostream&
operator<<(ostream& os, const Parent& b) {
return os << "Parent: " << b.i << endl;
}
};

Hi,

Im having difficulty in understanding copy constructors so the operator overloading.can any one explain me in detail the following program and how copy constructor works.I also dont understand why b.i is used in the constructor initializer list.


Thanks in advance,