I'm having trouble with an ambiguos operator.

I declared to overloaded operators, '='. One takes unsigned long, the other takes a double.

Now the problem is the compiler can't tell which function I want to use when passing 0.

example:

long ClassX::operator= (double test)
{
long result=0;
//do testing
return result;
}
long ClassX::operator= (unsigned long test)
{
long result=0;
//do testing
return result;
}

//some code later in main
ClassX xclass;
xclass=0;


This causes Ambigous error, it doens't know if i mean double or unsigned long.
Is there a way to specify which to use as default? or is there another solution?
Pass 0.0 for the double, 0L for the long.
It tried to put 0L but it still does not understand. I even tried (unsigned long).

I was able to force it beyond it's limited common sense using (unsigned long).

It should be default that if I put 0.0 i mean double, and 0 for int values.
Last edited on
Topic archived. No new replies allowed.