class farther
{
public:
virtual intro()
{
printf("I'm the father/n");
}
};
class son ublic farther
{
public:
intro()
{
printf("I'm the son/n");
}
};
class grandson ublic son
{
public:
intro()
{
printf("I'm the grand son/n");
}
};
main()
{
farther *a,*b,*c;
a = new farther;
b = new son;
c = new grandson;
a->intro();
b->intro();
c->intro();
}
运行结果是
I'm the father
I'm the son
I'm the grand son