So i have a project I'm working on with quite a hierarchy. In the base class of this there is a function reset() that gets called throughout all the derived classes. All I'm confused about is that, since this reset in the derived class basically just resets it's private variables and then calls it's preceding (higher) class' reset() function does the reset function have to be virtual?
Eg.
class Base
{
private:
int some;
public:
void reset();
};
class Derive : public Base
{
private:
int some1;
public:
void reset();
};
class Derive_two : public Derive
{
private:
int some2;
public:
void reset();
};
So basically the Derive_two class' reset function will then look as follows.
void Derive_two::reset()
{
some2 = 10;
Derive::reset();
}
Is this code right? Or does function reset() need to be of type virtual?
Any and help is appreciated, thank-you.