gpt4 book ai didi

c++ - 未声明的标识符错误 C++,我做错了什么我不知道?

转载 作者:行者123 更新时间:2023-11-28 07:27:10 25 4
gpt4 key购买 nike

当我运行这个项目时,我得到这个错误

  6 error C2065: 'Engine_in':undeclared identifier

我真的不知道我做错了什么。通常我可以弄清楚并知道我做错了什么,但是我没有深入研究单独的文件类。老实说,我不知道错误来自哪里。我用谷歌搜索了它,但每个人的问题都是具体的,所以这就是为什么我求助于你来解决我的问题。我提前道歉,因为我知道的不多。

我有这个类 'Engine_debug.cpp'

//Engine Debugger

#include<iostream>
#include "Engine_debug.h"
#include "Engine_in.h"

using namespace std;

Engine_debug::Engine_debug()
{
Engine_in input;
}

然后我有这个标题'engine_debug.h'

#ifndef Engine_debug_H
#define Engine_debug_H

class Engine_debug
{
public:
Engine_debug();
protected:
private:
}

#endif

我也有这个类 'Engine_in.cpp'

//Engine input

#include<iostream>
#include<string>
#include "Engine_in.h"

using namespace std;

Engine_in::Engine_in()
{

}

string askYN(string question, int format)
{...working code}

还有一个,另一个标题'Engine_in.h'

#ifndef Engine_in_H
#define Engine_in_H

class Engine_in
{
public:
Engine_in();
std::string askYN(std::string question, int format = 0);
protected:

private:
};

#endif

如果有人知道我做错了什么并想向我解释,请做,谢谢。

最佳答案

如果不是打错了,是你在定义成员函数的时候忘记写类名了。

string Engine_in::askYN(string question, int format)
// ^^^^^^^^^^ Missed during member function definition

不确定这是否会导致编译器提示的那种错误消息。

Engine_debug 类定义的末尾还缺少一个 ;。感谢杰西。

关于c++ - 未声明的标识符错误 C++,我做错了什么我不知道?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18565136/

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