c++ - 错误 C2514 : 'BLOCK'  : CLASS HAS NO CONSTRUCTOR

标签 c++

我收到错误 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/

相关文章:

c++ - TSP 的动态方法

c++ - 如何检测 atof 或 _wtof 是否失败?

c++ - 如何在if语句中定义变量和比较值?

c++ - 根据窗口大小动态更改 QToolButtons 的 ToolButtonStyle

c++ - 如何使用 API 将 map<string,string> 传递给 py?

c++ - 立即使用 boost::asio 检测写入期间关闭的 TCP 连接

c++ - clock_gettime() 返回错误的结果(VirtualBox 上的 Debian wheezy)

c++ - 如果我将所有这些放在不同的功能中是个好主意吗?

CodeBlocks 和 Xcode 中的 C++ 编译器错误

c++ - OpenGL:如何在不移动整个场景的情况下移动二维对象?