Hey Everyone,
So I have run into a problem with my ABC design in C++. I'm going to use a simplified example from what I actually have. Please ignore any syntax errors until I get to where my issue is.
So I have an ABC:
class ABC
{
public:
virtual void DoSomething() = 0;
};
Then I have a derived class:
class Derived: public ABC
{
public:
void DoSomething() { // something }
};
In my main logic function I have something along the lines of:
ABC* obj = new Derived;
obj->DoSomething();
Now at this point my code works beautifully, I have multiple classes functioning correctly based on if I change the type (manually for now) from one derived class to another using the abstract base class as the type for the derived objects.
Now my issue...
If I want to change my derived class to add in functionality that is not supported by the ABC then my compiler is not recognizing them whatsoever. For example if I leave ABC the way it is and change Derived to:
class Derived: public ABC
{
public:
void DoSomething() { // something }
void DoSomethingElse() { // something else, not defined in ABC}
};
Then back to my main logic function:
ABC* obj = new Derived;
obj->DoSomething();
// Compiler does not recognize this, due to not being in the "ABC" class
obj->DoSomethingElse();
My compiler keeps giving me errors that "DoSomethingElse()" is not a member of the ABC. Is what I am trying to do possible? It feels like I am overlooking something simple but I've hit this road block in my architecture of this piece of software. Any help is greatly appreciated.