Okay, so I know there are a lot of polymorphism threads flying around but I have yet to encounter this situation.
class Base {
public:
virtual void method1() {
cout << "BaseMethod1" << endl;
}
void method2() {
cout << "BaseMethod2" << endl;
}
};
class Derive: public Base {
public:
void method1() {
cout << "DeriveMethod1" << endl;
method2();
}
void method2() {
cout << "DeriveMethod2" << endl;
}
};
int main() {
Base* p = new Derive();
p->method1();
}
What's tripping me up is method1 in the derived class calls a method2. So which method2 would it be since the method2 in the Base class wasn't declared as virtual?
Thanks ahead of time!