I have the following function inside a class:
void solveMaze::getLoc() {
mouse m;
x = m.x;
y = m.y;
coords c(x, y);
cout << c << endl;
}
This is Coords class, Is this the right way to overload the << operator?:
class coords {
public:
coords(int, int);
int x;
int y;
coords& operator<<(const coords& rhs);
};
coords& coords::operator<<(const coords& rhs) {
cout << x << " " << y << endl;
}
coords::coords(int a, int b) {
x = a;
y = b;
}
I get an error "no match for operator<<"