#include<iostream>
using namespace std;
class A
{
public:
virtual void f()
{
printf("A.f called.\n");
}
};
class X:public A
{
public:
static const int b = 10 ;
int cvalue()
{
return c;
}
private:
int c ;
public:
X()
{
c =20;
}
void f()
{
cout<<"f called."<<endl;
}
};
int main()
{
X x;
cout<<x.b<<endl;
cout<<x.cvalue()<<endl;
x.f();
cout<<"----------------------------------"<<endl;
memset(&x, 0x0, sizeof(X));
cout<<x.b<<endl;
cout<<x.cvalue()<<endl;
x.f();
cout<<x.cvalue()<<endl;
x.f();
cout<<"_______________________"<<endl;
A* a = new X;
a->f();
memset(a, 0x0, sizeof(X));
//vptr is null.
a->f();
delete a;
return 0;