#include #include "derived.h" using namespace std; derived::derived() { cout << "default construct derived "; print(); cout << "\n"; } derived::derived(int initial_o1, int initial_o2, int initial_o3, int initial_o4) : base(initial_o1, initial_o2), o3(initial_o3), o4(initial_o4) { cout << "construct derived "; print(); cout << "\n"; } derived::~derived() { cout << "destruct derived "; print(); cout << "\n"; } /* void derived::print() const { o1.print(); //won't compile, because o1 is private member of class base cout << ", "; o2.print(); cout << ", "; o3.print(); cout << ", "; o4.print(); } */ void derived::print() const { base::print(); //will compile, because print is a public member of class base cout << ", "; o3.print(); cout << ", "; o4.print(); }