#include struct A { A() {} A(const A& a) { std::cout << "A COPY CONSTRUCTOR" << std::endl; } void operator=(const A& a) { std::cout << "A ASSIGNMENT OPERATOR" << std::endl; } }; struct Derived { A a; int* ip; int array[4]; Derived() { ip = new int; memset(array, 0, sizeof(array)); } }; int main(int argc, char** argv) { Derived d1; // implicityly defined copy constructor for class Derived does memberwise copy // calls copy constructor for members which are class objects -- Derived::A's copy constructor // scalar members, the assignment operator is used -- Derived::ip is copied by assignment // elements of arrays are copied element by element depending on if they are a class or scalar -- Derived::array is scalar Derived d2(d1); // implicitly defined assignment operator for class Derived does memberwise assignment // calls assignment operator for members which are class objects -- Derived::A's copy constructor // scalar members, the assignment operator is used -- Derived::ip is copied by assignment // elements of arrays are copied element by element depending on if they are a class or scalar -- Derived::array is scalar d2 = d1; // yes this program leaks memory return 0; }