|
| |
#include <iostream.h>
class C;
class A
{
public:
A() { f(); }
virtual void DO() { cout << "A::DO()\n"; }
private:
virtual void f() { cout << "A::f()\n"; }
void test() { cout << "A::test()\n"; }
friend class C;
};
class B : public A
{
private:
virtual void DO() { cout << "B::DO()\n"; }
virtual void f() { cout << "B::f()\n"; }
};
class C
{
public:
C(B *b) : m_pB(b) { m_pB->test(); }
private:
B* m_pB;
};
void main()
{
(1) B *b = new B;
A *a = b;
(2) a->DO();
(3) C c(b);
delete b;
}
What would the output for step 1,2 and 3 ?
|