Consider the following example:
struct Base
{
void foo()
{
cout << "Base foo\n";
}
void bar()
{
cout << "Base bar\n";
}
};
struct Derivate : public Base
{
void foo(int x)
{
cout << "Derivate foo\n";
}
};
If we create two instances, like
Base a;
Derivate b;
The Base
object a
can call its member functions as usual (a.foo(); a.bar();
).
When using b
the call b.bar()
works as expected but since I overloaded Base::foo()
it's not possible to call b.foo()
.
Why is that?