include iostream using namespace std struct virtual void AA cout AA en

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;
struct a
{
virtual void AA() { cout << "AA" << endl; }
};
struct b : a
{
void AA() { cout << "BB" << endl; }
};
int main()
{
a* A = new b();
A->AA();
return 0;
}