#include<iostream>
using namespace std;
typedef void(*Fun) ();
struct AA
{
Fun _fun;
int _a;
};
struct BB
{
AA a;
int _b;
};
void funA()
{
printf("funA()\n");
}
void funB()
{
printf("funB()\n");
}
int main()
{
AA aa;
BB bb;
aa._fun = funA;
bb.a._fun = funB;
AA *p = &aa;
p->_fun();
p = (AA*)&bb;
p->_fun();
system("pause");
return 0;
}
C语言模拟实现C++的继承多态
最新推荐文章于 2021-04-10 18:55:09 发布