We just started learning about classes and operator overloading in my computing module and I have a problem with one of the examples given:
#include <iostream>
using namespace std;
int main()
{
class PositivePoint
{
// Must return PositivePoint object by value
PositivePoint operator+(const PositivePoint& pSrc);
};
PositivePoint PositivePoint::operator+(const PositivePoint& pSrc)
{
Positive Point ret;
ret.mX = mX + pSrc.mX;
ret.mY = mY + pSrc.mY;
return ret;
}
// Return success
return 0;
}
I keep getting the error "unqualified-id in declaration before '(' token. I do not understand why this is the case since I thought that operator overloading was correctly defined in the above example.