#include <iostream>
using namespace std;
struct A{
virtual void f(){
cout<<"a"<<endl;
}
};
struct B:public A{
void f(){
cout<<"b"<<endl;
}
};
struct C:public B{
void f(){
cout<<"c"<<endl;
}
};
int main(){
C c;
A* a=&c;
B* b=&c;
a->f();
b->f();
}
====out====
c
c
No comments:
Post a Comment