源代码是这样的
class CBase
{
public:
virtual void MemberFun(void)
{
cout<<"void CBase::MemberFun(void)"<<endl;
}
virtual void MemberFunction(int)
{
cout<<"void CBase::MemberFun(int)"<<endl;
}
};
class CDeriver:public CBase
{
public:
void MemberFun(void)
{
cout<<"void CDeriver::MemberFun(void)"<<endl;
}
class CBase
{
public:
virtual void MemberFun(void)
{
cout<<"void CBase::MemberFun(void)"<<endl;
}
virtual void MemberFunction(int)
{
cout<<"void CBase::MemberFun(int)"<<endl;
}
};
class CDeriver:public CBase
{
public:
void MemberFun(void)
{
cout<<"void CDeriver::MemberFun(void)"<<endl;
}
};
// test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "sytax.hpp"
int _tmain(int argc, _TCHAR* argv[])
{
::CDeriver cDeriberd;
::CBase *pcBase = &cDeriberd;
::CDeriver *pcDeriber = &cDeriberd;
pcBase->MemberFun();
pcDeriber->MemberFun();
//pcBase->MemberFun(1);
cDeriberd.MemberFunction(1);
return 0;
}
输出的结果是: