缺少类型说明符 - 假定为 int(class 问题)

missing type specifier - int assumed (class issue)

所以我正在使用 sfml 制作一个非常简单的游戏,但 运行 遇到了这个问题。我在使用相同的 classes 和设计等之前制作了一个游戏。但是我在 Player* player; 和另一个 class Level level .

中遇到了问题

这次我做错了什么。我不记得我上次为这个特定部分做了什么(因为我没有 运行 进入这个问题)而且我没有文件了。

这是头文件。

#pragma once
//level.h

//includes
#include "Player.h"
#include "GameObject.h"
#include <vector>
#include <ctime>
#include <SFML\Window\Keyboard.hpp>

//usings
using std::vector;
using sf::Keyboard;
class Level
{
public:
    Level();
    ~Level();
    void Update(), Render(sf::RenderWindow& window);
private:
    Player* player;
    void HandleInput(), Randomise(), Reset(), UserInterface(), Collisions(), GenerateObjects(), MoveObjects();

    vector<GameObject*> levelObjects;
    sf::FloatRect rectCollectible[5], rectPlayer;
    sf::Text timeText, scoreText;
    sf::Font font;
    sf::SoundBuffer collectibleBuffer;
    sf::Sound collectibleSound;
    sf::Texture spritesheet;
    bool mute, paused;
    int randomiser, spawnDelay, maxObjects;
};

这似乎是一个循环依赖问题。参见 Resolve header include circular dependencies

您需要像这样转发声明 Player 并取出 Player.h 的包含:

#pragma once
//level.h

//includes
//#include "Player.h"
#include "GameObject.h"
#include <vector>
#include <ctime>
#include <SFML\Window\Keyboard.hpp>

//usings
using std::vector;
using sf::Keyboard;
class Player;
class Level
{
public:
    Level();
    ~Level();
    void Update(), Render(sf::RenderWindow& window);
private:
    Player* player;
    void HandleInput(), Randomise(), Reset(), UserInterface(), Collisions(), GenerateObjects(), MoveObjects();

    vector<GameObject*> levelObjects;
    sf::FloatRect rectCollectible[5], rectPlayer;
    sf::Text timeText, scoreText;
    sf::Font font;
    sf::SoundBuffer collectibleBuffer;
    sf::Sound collectibleSound;
    sf::Texture spritesheet;
    bool mute, paused;
    int randomiser, spawnDelay, maxObjects;
};