所以今天我写了一些C++, 经过很长一段时间的中断, 一个简单的坐标系统, 我想我要一个建构器 以2个值计算, 这样我就可以写一些东西, 比如“坐标C =新的坐标( 1, 2) ” ; ; ; ; ; ; ; ; ; ; ; ”
struct Coordinates {
int x;
int y;
Coordinates(int a, int b) {
x = a;
y = b;
}
};
在Cygwin编译时,我得到:
$ 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)
不知道这里出了什么问题 我找不到关于C++结构构建器的信息 有什么想法吗?