So I wrote some C++ today after a long break for a simple coordinate system and I figured I'd want a constructor to take in 2 values so that I could write things like "Coordinates c = new Coordinates(1,2);"
struct Coordinates {
int x;
int y;
Coordinates(int a, int b) {
x = a;
y = b;
}
};
When compiled in Cygwin, I get:
$ g++ -o adventure adventure.cpp adventure.cpp:36: error: no matching function for call to `Coordinates::Coordinates()' adventure.cpp:22: note: candidates are: Coordinates::Coordinates(const Coordinates&) adventure.cpp:26: note: Coordinates::Coordinates(int, int)
Not sure what's going wrong here and I can't find much info on C++ struct constructors. Any ideas?
Coordinates c;? If so, that's not legal because you have no way to construct aCoordinateswithout either the two integer parameters or anotherCoordinates.Coordinates c(1,2);