即使使用默认构造函数仍然有错误。
class Foo {
public:
Foo ( int x, int y, int type );
}
在 .cpp 文件中
Foo::Foo ( int x = 0, int y = 0, int type = 0 ) {
然而,当我调用它时
Foo foo_array[5][5];
我得到了错误。这可能是什么原因?
最佳答案
将默认参数放在构造函数的声明中。实际上,当您尝试创建数组时,编译器并不知道它们。
关于c++ - 错误 C2512 : 'Tile' : no appropriate default constructor available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14991883/