K
klessard
Hi,
Here's a very simple inheritance case that cause me some problems:
class A
{
public:
void Bob(int i) { cout << "in A::Bob(int)" << endl; }
};
class B : public A
{
public:
void Bob() { cout << "in B::Bob" << endl; }
};
main()
{
A a;
B b;
a.Bob(0);
b.Bob();
b.Bob(0); << ERROR: No Bob(int) can be found
}
On the last line, my compilers (GCC 3.3.5 and 3.4.2) tells me that no
Bob(int) can be found. Without the Bob() method in class B, there's no
problem.
This is incredible for me, I probably miss something somewhere, cause
this should be very basic C++ stuff. The compiler should check if a
method is defined in a class, and if not, it checks in the base class.
So why it doesn't do the same with function sharing the same name? Any
Help?
Thanks,
Karl
Here's a very simple inheritance case that cause me some problems:
class A
{
public:
void Bob(int i) { cout << "in A::Bob(int)" << endl; }
};
class B : public A
{
public:
void Bob() { cout << "in B::Bob" << endl; }
};
main()
{
A a;
B b;
a.Bob(0);
b.Bob();
b.Bob(0); << ERROR: No Bob(int) can be found
}
On the last line, my compilers (GCC 3.3.5 and 3.4.2) tells me that no
Bob(int) can be found. Without the Bob() method in class B, there's no
problem.
This is incredible for me, I probably miss something somewhere, cause
this should be very basic C++ stuff. The compiler should check if a
method is defined in a class, and if not, it checks in the base class.
So why it doesn't do the same with function sharing the same name? Any
Help?
Thanks,
Karl