我收到错误 error C2514: 'BLOCK' : CLASS HAS NO CONSTRUCTOR
有一个像这样的简单类:
block .h
#pragma once
#include "helpful.h"
class WORLD;
class BLOCK
{
public:
short int type;
void Render();
BLOCK();
~BLOCK(void);
};
block .cpp
#include "BLOCK.h"
#include "WORLD.h"
BLOCK::BLOCK(void)
{
}
void BLOCK::Render()
{
}
BLOCK::~BLOCK(void)
{
}
但是 BLOCK
类已经定义了,不是吗?
最佳答案
我发现我的错误:对 BLOCK
的构造函数的调用在另一个文件中,但是 BLOCK
的 header 不包括在内,我只有 类 block ;
。将其更改为 #include BLOCK.h
,问题已解决。
关于c++ - 错误 C2514 : 'BLOCK' : CLASS HAS NO CONSTRUCTOR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4769629/