没有匹配函数来调用"AnimationSet::AnimationSet()"
No matching function for call to 'AnimationSet::AnimationSet()'
我只是在做我的DrawObject构造函数,并不断遇到这个错误:
C:CodeBlocksSDLGameDrawObject.cpp|3|error: no matching function for call to 'AnimationSet::AnimationSet()'|
C:CodeBlocksSDLGameDrawObject.cpp|3|note: candidates are:|
C:CodeBlocksSDLGameAnimationSet.h|9|note: AnimationSet::AnimationSet(int)|
C:CodeBlocksSDLGameAnimationSet.h|9|note: candidate expects 1 argument, 0 provided|
C:CodeBlocksSDLGameAnimationSet.h|5|note: AnimationSet::AnimationSet(const AnimationSet&)|
C:CodeBlocksSDLGameAnimationSet.h|5|note: candidate expects 1 argument, 0 provided|
这是我的动画集:
class AnimationSet
{
public:
AnimationSet(int animationCounter);
virtual ~AnimationSet();
int getCurrentFrame();
void setCurrentFrame(int currentFrame);
int getCurrentAnimation();
void setCurrentAnimation(int currentAnimation);
private:
int currentFrame;
int curretAnimation;
Animation* animations;
};
我的drawObject构造函数:
drawObject::drawObject(char* name, char* surfaceFile, int xPos, int yPos, int drawLevel, bool willMoveVar, bool isSpriteVar, int animationNumber)
{
animationSet = new AnimationSet(animationNumber);
name = name;
xPos = xPos;
yPos = yPos;
willMoveVar = willMove;
}
您提供的代码没有显示错误在哪里,但我猜您在drawObject
中有AnimationSet
成员对象,这意味着,在没有默认构造函数的情况下,您必须在构造函数初始化列表中初始化它。
drawObject::drawObject(char* name, char* surfaceFile, int xPos, int yPos, int drawLevel, bool willMoveVar, bool isSpriteVar, int animationNumber) :
animationSet(animationNumber) //I'm assuming this isn't a pointer
{
name = name;
xPos = xPos;
yPos = yPos;
willMoveVar = willMove;
}
相关文章:
- 什么时候调用组成单元对象的析构函数
- 对RValue对象调用的LValue ref限定成员函数
- 为什么使用 "this" 指针调用派生成员函数?
- 函数调用中参数的顺序重要吗
- OpenGL - 在抛出"__gnu_cxx::recursive_init_error"实例后终止调用?
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 在c++类上调用void函数
- 为什么 std::unique 不调用 std::sort?
- 调用专用模板时出错"no matching function for call to [...]"
- 选择要调用的构造函数
- C++为什么尽管我调用了void函数,它却不起作用
- 构造函数正在调用一个使用当前类类型的函数
- 变量没有改变?通过向量的函数调用
- 没有为自己的结构调用列表推回方法
- 调用'begin(int [n])'没有匹配函数
- 什么时候调用析构函数
- 如何用参数值调用函数(仅在运行时已知)
- std::cout.imbue()多重调用
- 没有匹配函数来调用"AnimationSet::AnimationSet()"