我得到:
main.cpp(13): error C2512: 'myPlayer' : no appropriate default constructor available
这是它引用的代码:
myPlayer player;
这是构造函数:
myPlayer (int myHealth, int myDamage, int myMoney, int myWeaponID, int myClass) : health(myHealth), damage(myDamage), money(myMoney),
weapon_id(myWeaponID), p_class(myClass) {}
此外,如何在 Visual Studio 11 上显示每行的编号?
最佳答案
您的构造函数被声明为采用 5 个参数,类型均为 int
。您没有提供任何参数。
您的选择是编写不需要参数的构造函数,或者在构造对象时提供参数,例如:myPlayer player(1, 2, 3, 4, 5);
关于c++ - 这是什么错误: "no appropriate default constructor available"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11387926/