//can assign the address of an object of a derived class to a pointer variable of its base class, but only through this pointer access a hidden object in the derived class that is inherited by the base class,//cannot access new members in the derived class. The same cannot be done in turn. #include <iostream>using namespace Std;class b{public:b () {cout<< "B" <<ENDL;} void Fun () {cout<< "B::fun ()" <<ENDL;} Private:int x;}; Class D:public B{public:d () {cout<< "D" <<ENDL;} void Fun () {cout<< "D::fun ()" <<ENDL;} void Show () {cout<< "D::show ()" <<ENDL;} Private:int y;}; void Main () {D D; B *PB = &d;pb->fun ();//Pb->d::fun (); Pb->show (); Error, a pointer variable through a base class cannot access a new member of a derived class}
C + + accesses hidden objects in derived classes that inherit from the base class through pointer variables of the base class