Is it possible to have a base class that has an instance of the derived class as a parameter to one of the base class’s functions? For example:
class A
{
virtual void foo(B b[]);
};
Class B: public A
{
void foo(B b[]);
};
Is this legal? Also class A will need to include the header file for class B, is this problematic as well?
It’s possible with a forward declaration:
but it’s a major code smell. Please state what you’re trying to achieve, this looks like a faulty design.