Yes. It's the type of object the pointer points too (class B), not the type of pointer (class A) that determines which method will be called.
If a class contains at least 1 pure virtual method the class become abstract, you cannot create instances of the class directly, only derived classes. Also the derived classes must provide their own overloaded versions of all the pure virtual methods.
Need to add public: for above to compile.
1 2 3 4 5 6 7 8 9
class A{
public:
virtualvoid display(){ cout<<"AA"<<endl; }
};
class B:public A{
public:
virtualvoid display(){ cout<<"BB"<<endl; }
};