Problem with overloaded function selection

Andrey Pozdeev AndreyPozdeev@rambler.ru
Mon Aug 12 03:22:00 GMT 2002


I tried to compile the following example using GCC and MS Visual C++:
-----------
class A
{
    public:
    A(){};
};

class B
{
    public:
    operator double() {return 0L;};
    operator int() { return 0; };
    operator A() { return A();};
};


void test(char){};
void test(A){};

int main()
{
  B b;
  test(b);
  return 0;
}
-------------
Both compilers compiles this example succesfully.
But if we comment line with 'operator double' or with 'operator int' then GCC 
will complain, Visual C++ will not.

What's the matter ?

Andrey.
----
  http://www.rambler.ru



More information about the Gcc-help mailing list