O
Oliver Graeser
Hi All,
I'm coming from Java to C++ and this is one of the very last problems I
have so far... In Java, if I have, say, a class SISNode that extends
NetworkNode, I can have a function that returns a NetworkNode but I can
assure the compiler that it is in fact a SISNode and therefore call the
method getStatus() that only a SISNode has. Like
SISnode s,t;
NetworkNode n;
n =t;
n.getStatus();//won't work
s= (SISNode) n;
s.getStatus(); //will work
....
....
I'm now looking for some way to do this in C++. I do agent-based network
simulations, and I want to derive all kinds of agents from a generic
network node type. This network node is supposed to store his neighbours
in a std::list<GenericNetworkNode> list. Now in the derived classes I
can obtain the neighbours, but I cannot call their methods unless they
were already declared in the GenericNetworkNode declaration.
Anybody knows how to solve this problem? A hint in the right direction
(keyword) would be more than enough....
Thanks
Oliver
I'm coming from Java to C++ and this is one of the very last problems I
have so far... In Java, if I have, say, a class SISNode that extends
NetworkNode, I can have a function that returns a NetworkNode but I can
assure the compiler that it is in fact a SISNode and therefore call the
method getStatus() that only a SISNode has. Like
SISnode s,t;
NetworkNode n;
n =t;
n.getStatus();//won't work
s= (SISNode) n;
s.getStatus(); //will work
....
....
I'm now looking for some way to do this in C++. I do agent-based network
simulations, and I want to derive all kinds of agents from a generic
network node type. This network node is supposed to store his neighbours
in a std::list<GenericNetworkNode> list. Now in the derived classes I
can obtain the neighbours, but I cannot call their methods unless they
were already declared in the GenericNetworkNode declaration.
Anybody knows how to solve this problem? A hint in the right direction
(keyword) would be more than enough....
Thanks
Oliver