Overloading a function like this
Here is my code - can anyone pls tell me why my compiler won't allow me to do this?
Code:
class TMyClass
{
public:
Ansistring Message();
char* Message();
private:
AnsiString sMessage;
};
my compiler won't allow me to overload Message() like this. Why?
(I use Borland C++Builder 5.0)
"This is illegal so the compiler won't allow it. "
I know that - but why is it illegal?
Thanx for the reply though.
Re: "This is illegal so the compiler won't allow it. "
Quote:
Originally posted by Koedoe
I know that - but why is it illegal?
Thanx for the reply though.
Because when you run the function Message(void) the compiler has two functions to choose from, and he doesn't know which one to take. This is illegal and illogical.
If the functions have different argument lists, then it knows which one to pick.