I have a class named ThreeDigits on c++ code. I overloaded the + operand, this way:
ThreeDigits* ThreeDigits::operator+(const ThreeDigits &number) const
{
double result= getNumber()+number.getNumber();
ThreeDigits* new_result=new ThreeDigits(result);
return new_result;
}
but when I write on the main function:
ThreeDigits* first=new ThreeDigits(2.55998);
ThreeDigits* second=new ThreeDigits(5.666542);
ThreeDigits* result=first+second;
I get the following compilation error: invalid operands of types ThreeDigits* and ThreeDigits* to binary operator+
Can you tell me what is the problem? thanks