1.11M Members

Interacting with derived class's functions from the base class

 
0
 

If I wanted to access a function that is in a derived class from it's base class, what would be the best way of doing so? I have experimented with functions like Interact( char *pCommand, char **pArgs ) which is inside the base class, and can be overidden by the derived class to access it's functions. But that doesn't really seem like the best way to do so. Can someone give me a suggestion or two as to what the best way to do this is. If you need a better explanation of what I'm trying to do, just ask.

 
0
 

The base class knows nothing about the existence of child classes, and should never even want to know.
If you think you have such a requirement, you have a fundamentally flawed design.

But most likely all you need are some virtual functions, which would make the whole thing happen implicitly, so the correct overridden function from a child class gets called from a non-overridden method in the base class when that method is used from an instance of that child class.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article