小女系C++初学者,碰到此问题非常困惑,现将程序尽量简单的描述如下,请各位耐心看完,指点迷津
class NsObject : public TclObject, public Handler {
public:
...
virtual void recv(Packet* p, const char* s);
...
protected:
...
void handle(Event*);
...
};
void NsObject::handle(Event* e)
{
recv((Packet*)e);
}
class BiConnector : public NsObject {
public:
...
protected:
...
void recv(Packet*, Handler* callback = 0);
...
}
void BiConnector::recv(Packet* p, Handler* h)
{
...
}
class Phy : public BiConnector {
public:
Phy();
void recv(Packet* p, Handler* h);
virtual void sendDown(Packet *p)=0; //此函数只有虚函数
.
.
.
}
Phy::recv(Packet* p, Handler*)
{
...
sendDown(p);
return;
...
}
当运行到phy::recv(p,h)的senddown(p)时,而phy类只有senddown的虚函数,程序是如何调用的?