// File: ex7-9.cpp
#include <iostream> using namespace std; class B { public: B() { cout << "B ctor called for " << this << endl; } void funk1() { cout << "B::funk1() called for " << this << endl; } void funk2() { cout << "B::funk2() called for " << this << endl; } }; class D : public B { public: D() { cout << "D ctor called for " << this << endl; }
// Override funk1()

void funk1()
{
cout << "D::funk1() called for " << this << endl;
}
};

int main()
{
B b;
D d;
cout << endl;

b.funk1();
d.funk1();
cout << endl;

b.funk2();
d.funk2();
cout << endl;

B* pB;
pB = &b;
pB->funk1();
cout << endl;

pB = &d;
pB->funk1();
cout << endl;

cout << "size of b = " << sizeof b << endl;
cout << "size of d = " << sizeof d << endl;
}