See below:
#include <iostream>using namespace std;class A{public: virtual void out() { cout << "Out from class A" << endl; }};class B : public A{public: void out() { cout << "Out from Class B" << endl; }};void main(){ A a; B b; a.out(); // echoes "Out from class A" b.out(); // echoes "Out from class B" A new_a = b; new_a.out(); // echoes "Out from class A", as expected, // since we are _COPYING_ the parts of b // that are of class A over to a new object of class A A* p_a = &b p_a->out(); // echoes "Out from class B", because it''s a pointer // type, and accesses the vtbl A& r_a = b; r_a.out(); // echoes "Out from class B", because (again) it''s a reference type (points-to)}