So, I wrote some C ++ today after a long break for a simple coordinate system, and I decided that I want the constructor to take 2 values so that I can 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: there is no corresponding function to call `Coordinates :: Coordinates () 'adventure.cpp: 22: note: candidates: Coordinates :: Coordinates (const Coordinates &) adventure. cpp: 26: note: Coordinates :: Coordinates (int, int)
Not sure what is going on here, and I cannot find much information about C ++ constructors. Any ideas?
source
share