16,471
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <iostream>
using namespace std;
class CWnd
{
public:
CWnd()
{
}
~CWnd()
{
}
void CreatEx();
virtual void PreCreateWindow()
{
cout << "CWnd::PreCreateWindow" << endl;
}
};
class CFrameWnd : public CWnd
{
public:
virtual void PreCreateWindow()
{
cout << "CFrameWnd::PreCreateWindow" << endl;
}
};
void CWnd::CreatEx()
{
PreCreateWindow();
}
int _tmain(int argc, _TCHAR* argv[])
{
CFrameWnd mainWnd;
mainWnd.CreatEx(); // 输出:CFrameWnd::PreCreateWindow
return 0;
}
是不是这个意思?
a* pA = (a*)(new b);
if(pA)
{
PA->f(); //此时调用的是b类的f()
}