E
engineer
Hi,
I have three classes NsObject, Biconnector, Phy.
class NsObject is parent class and has a pure virtual function 'recv( )'.
class Biconnector derived from NsOject.
class Phy derived from Biconnector.
both Biconnector and Phy have their own implementation for function recv.
class NsObject {
public:
Virtual void recv( ) = 0; //so this is pure virtual function
};
//---------------------------------------------------
class Biconnector : public NsObject {
Protected:
Void recv( ) {
Cout<<” I am biconnector: “;
}
NsObject * uptarget;
}
//---------------------------------------
class phy: public biconnector {
Public:
Void recv( ) {
uptarget->recv( ); //which function does this line calls
}
}
//------- End of coding-------------
If I call phy::recv(), it will in turn execute uptarget->recv ( );,
This confuses me, as uptarget is a pointer of type NsObject and NsObject does not have implementation for recv ( ).
so which statements will be executed for "uptarget->recv( )"
thanks in advance.
- Ahmed
I have three classes NsObject, Biconnector, Phy.
class NsObject is parent class and has a pure virtual function 'recv( )'.
class Biconnector derived from NsOject.
class Phy derived from Biconnector.
both Biconnector and Phy have their own implementation for function recv.
class NsObject {
public:
Virtual void recv( ) = 0; //so this is pure virtual function
};
//---------------------------------------------------
class Biconnector : public NsObject {
Protected:
Void recv( ) {
Cout<<” I am biconnector: “;
}
NsObject * uptarget;
}
//---------------------------------------
class phy: public biconnector {
Public:
Void recv( ) {
uptarget->recv( ); //which function does this line calls
}
}
//------- End of coding-------------
If I call phy::recv(), it will in turn execute uptarget->recv ( );,
This confuses me, as uptarget is a pointer of type NsObject and NsObject does not have implementation for recv ( ).
so which statements will be executed for "uptarget->recv( )"
thanks in advance.
- Ahmed