|
From: Abhijit S. <mu...@gm...> - 2003-07-28 18:13:29
|
> unsigned char operator()()
> {
> return (unsigned char) m_n;
> };
> long operator()()
> {
> return (long) m_n;
> };
> };
>
> Compiling this tells me that the () operators cannot be overloaded! If I
> remove one of them, then it compiles just fine. Are you going to tell me
> that I can only overload the () operator once?
Overloading is having a different parameter list, not different return
values. Here, you have the same parameter list, so the compiler generates
the same signature. That's why the error.
You should have only one operator, which returns the actual type of m_n. It
is up to the user of the class to cast it. This way, you ensure that the
end-user knows that he's casting, and knows that he can get into trouble
that way.
--
Abhijit Shylanath
Homepage: http://mudeth.tripod.com/
|