For some reason my overloaded operators work fine when I compile on visual studio but when I compile on g++ in linux I get the following errors:
main.cpp:66:4: error: no match for ‘operator=’ (operand types are ‘UVLI’ and ‘UVLI’) f = a + b;
For some reason it appears to be looking for an overloaded operator= which takes UVLI, UVLI and I don't know why.
Here are my operators:
UVLI UVLI::operator+(unsigned long number) const
{
UVLI result, right;
UVLI left((*this));
right.long2UVLI(number);
result.add(left, right);
return result;
}
UVLI UVLI::operator+(UVLI &right) const
{
UVLI result;
UVLI left((*this));
result.add(left, right);
return result;
}
void UVLI::operator=(unsigned long number)
{
this->long2UVLI(number);
return;
}
void UVLI::operator= (UVLI &right)
{
this->copy(right);
return;
}
All I am doing in my main function is:
UVLI f;
f = a + b;
Does anyone know why g++ is not using my + operator, and instead trying to find =(UVLI, UVLI)?
I'm not to worried of the contents inside of the operator is wrong, I just want it to call correctly.
Thanks.