#include <iostream> using namespace std; class X { public: X () { f (); cout << endl; } virtual void g () { cout << 1 << ' '; } void f () { g (); } }; class Y: public X { public: Y () { f (); cout << endl; } void g () { cout << 2 << ' ';} void f () { g(); } }; class Z: public Y { public: Z () { g (); f (); cout << endl; } void g () { cout << 3 << ' '; } void f () { g(); } }; X x; Y y; Z z; X * px = &x; Y * py = &y; Z * pz = &z; void out ( void ) { px->f (); px->g (); py->f (); py->g (); cout << endl; } int main () { out (); px = py; out (); py = pz; out (); return 0; }
template <class T> Matrix<T>& MatMult ( Matrix<T>& A, Matrix<T>& B );