I am writing a set of classes that inherit from one-another as follows:
I have a function in Class2 that needs to accept any of the classes as a parameter. Can I just have it accept the BaseClass as the parameter (I only need access to the BaseClass variables), like this:
-or- do I need to override the function for each class (ick):
Please tell me that I can just do a parameter of the BaseClass, it would make things so much simpler!
-Miq
Code:
<BaseClass>
/ \
<Class1> <Class2>
I have a function in Class2 that needs to accept any of the classes as a parameter. Can I just have it accept the BaseClass as the parameter (I only need access to the BaseClass variables), like this:
Code:
class Class2 : public BaseClass
{
public:
Func(BaseClass&);
private:
int C2;
};
-or- do I need to override the function for each class (ick):
Code:
class Class2 : public BaseClass
{
public:
Func(BaseClass&);
Func(Class1&);
Func(Class2&);
private:
int C2;
};
Please tell me that I can just do a parameter of the BaseClass, it would make things so much simpler!
-Miq