[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
C++ Blues.
As much as I like it, sometimes C++ agravates me entirely.
OK suppose you have a class Mummy, and a class Kiddie which
is publicly derived from Mummy.
Now Mummy has a method TellMe(), as well as the method
TellMe(char* Secret).
Kiddie overrides TellMe(), but not TellMe(char* Secret),
(It is irrelevant whether TellMe() is virtual or not, I
tired both).
So now I try something like
Kiddie jane;
jane.TellMe("Hello World")
So you would Mummy::TellMe(char* ) to get called, wouldn't
you. g++ just complains that Kiddie::TellMe(char*) there
is no match for call to Kiddie::TellMe(char*), but
Kiddie::TellMe() is a candidate.
It all works if I disable or rename Kiddie::TellMe().
Is this
A) Some stupid error I have made.
B) A compiler bug.
C) Something absolitulely mad in the C++ language.
Maybe someone can reproduce the problem. Attached is a
test program.
#include <iostream.h>
class Class1{
public:
void Meth(void){};
void Meth(int i){
cout << i << " Miles per Hour\n";
}
};
class Class2 : public Class1{
public:
void Meth(void){cout << "Vrrroooom ";}
};
void main() {
Class2 o2;
o2.Meth(23);
}