gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 21:07:33 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com