0
Here is an example:
class A{
public:
void print(){
cout << "I am A" << endl;
}
};
class B: public A{
public:
void print(){
cout << "I am B" << endl;
}
};
int main(){
B* b = new B;
b->print(); //It prints "I am Bâ
A* a = b;
a->print(); //It prints "I am A"
return 0;
}
HOWEVER, if in class A, the method print was declared as virtual, both calls to print would call B's print because the "real" type of the variable b (and a) is B. They are an instance of object B (because of new B)



