#include<iostream>
using namespace std;
class A{
public:
virtual void f1()
{
cout<< "in A:: f1()"<<endl;
}
};
class B : public A{
public:
void f1()
{
cout<<"in B: f1()"<<endl;
}
virtual void f2()
{
cout<<"in B: f2()"<<endl;
}
};
int main()
{
A *pa = new B;
pa->f1();
pa->f2(); // Compile error as f2() is not known to base class
}
No comments:
Post a Comment