'Input' 不会命名类型错误。不知道为什么?
'Input' does not name a type error. Can't figure out why?
当我编译时,我得到错误:'Input'没有在第17行命名类型
#ifndef GAME_H
#define GAME_H
#include "input.h"
// Can forward declare "class Input(GLFWwindow*);" here but it still
// gives the same error.
class Game
{
public:
Game(Input* input);
~Game();
void Input();
void Update();
void Render();
private:
Input* mpInput; //error here.
};
#endif // GAME_H
Input.h是这样的
#ifndef INPUT_H
#define INPUT_H
#include <GLFW/glfw3.h>
#include <vector>
class Input
{
public:
Input(GLFWwindow* window);
~Input();
bool GetKey(int keyCode);
bool GetKeyDown(int keyCode);
bool GetKeyUp(int keyCode);
void Update();
private:
GLFWwindow* mpWindow;
std::vector<bool> mCurrentKeys;
std::vector<bool> mDownKeys;
std::vector<bool> mUpKeys;
const int NUM_KEYCODES = 256;
};
#endif // INPUT_H
我不知道这里发生了什么。我昨天遇到了类似的问题,无法解决,所以我尝试保存项目,关闭Code::Blocks,重新启动Code::Blocks,然后重新打开项目。然后我编译了它,它没有明显的原因就工作了。没有更改代码或其他内容。我试着在这里重新加载项目,但它仍然给出相同的错误。
在类代码中有方法Input
。混合方法和类型的名称通常不是一个好主意。在您的一个类Game
方法中考虑以下代码:
Input();
这是一个方法Input
调用或您正在尝试创建Input
类实例?试着重命名你的Input
方法
相关文章:
- 我不知道导致错误的原因 (C3074)
- 我正在尝试制作一个自平衡机器人,但编译时存在错误。我不知道如何解决它
- 反转字符串.不知道为什么这个逻辑是错误的.C++
- MSVC 在不知道类型的情况下评估上下文(和错误)
- 函数抛出seg错误,我不知道为什么
- 尝试通过多个函数移动数组,但遇到了我不知道如何修复的错误
- 由于某种原因,我的代码中出现了 [json.exception.type_error.302]。我知道错误意味着什么,但我不知道哪里有故障
- "错误:在'.标记'之前出现预期的主表达式,我不知道为什么
- 我正在制作c ++代码,但发生错误我不知道为什么
- std::cout << glGetString(GL_RENDER) << std::endl;抛出错误但不GL_Renderer或GL_Verision,我不知道为什么?
- 合成错误不知道为什么会发生这种情况,请检查一下并告诉我这是我的编码还是视觉工作室
- 语法检查器指出一些我不知道为什么的错误
- 编写蒙特卡洛集成程序,我不知道为什么我会收到某些错误
- 我不断收到分段错误,但不知道是什么原因造成的
- 我通过编译器C 11收到了UVA在线法官的错误消息.我永远不知道为什么会产生此错误
- 不知道为什么我收到有关 std::size_t 不包含参数包的编译错误
- C++代码出现分段错误,我不知道为什么
- 我不知道如何使用 boost,虽然我的老师确实提供了代码,但我遇到了一个错误
- 我同时使用了莱布尼茨和瓦利斯公式来估算π但输出数字错误,我不知道我哪里出错了
- 错误数组用作初始值设定项,我不知道错误