Hello everyone,
I am just a little confusing and not 100% confident about the following case. In the following sample, function call foo (called in function goo in class Foo) will call foo in class Goo, other than foo in class Foo, because we are using an instance of Goo g and no matter in which class, right?
(I have tested the result is correct, and I am asking the reason here.)
Code:
#include <iostream>
using namespace std;
class Foo {
public:
void goo()
{
foo(); // will call foo in class Goo
}
private:
virtual void foo() = 0;
};
void Foo::foo()
{
cout << "I am here. " << endl;
}
class Goo : public Foo {
public:
void foo()
{
Foo::foo();
}
};
int main()
{
Goo g;
g.foo();
return 0;
}
thanks in advance,
George