使用的编译器:VS2010
基类:父类
派生类:Child0类
实例与调用:MainFrame(Child0类)
class parent /*parent Class*/
{
public: /*Base Func*/
virtual void OnAutoEntry();
virtual void OnInitParam(){};
virtual void OnInitSequence(){};
virtual void OnRunSequence(){};
private:/*Private Call Func*/
void OnSeqInitPartFunc();
void OnSeqStartDoneFunc();
}
void parent::OnAutoEntry() //doesn't understand function action
{
// How did the parent class know the child function and called it?
OnInitParam();
OnSeqInitPartFunc();
OnSeqStartDoneFunc();
}
class child0 : public parent
{
void OnAutoEntry(); //propose : overridding
void OnInitParam(); //propose : overridding
void OnInitSequence(); //propose : overridding
void OnRunSequence(); //propose : overridding
}
在child0类上创建覆盖函数。
void child0::OnInitParam()
{AfxMessageBox(_T("Child :: OnInitParam() Called By Parent"));}
OnInitSequence,OnRunSequence是相同的东西。
我在MainFrame上调用此函数
void child0::OnAutoEntry()
{parent::OnAutoEntry(); //call parent function}
我的预期结果:无效。没有打印的消息。
但是结果是消息已打印。