When I try compiling a CPP file that contains the following class:
class Point {
public:
Point(int x = 1, int y = 1): x(x), y(y) {}
Point operator+(const Point& p1, const Point& p2)
{
/* some code */
}
private:
int x;
int y;
};
I get the error: must take either zero or one argument
. Actually I've found some similar questions but I couldn't get the answer that made me understand the reason behind that. Why is it forbidden to give it two arguments and why is it legal when we declare the function as friend
?