未知的覆盖说明符和缺少的类型说明符 - Visual Studio 2017

时间:2018-01-31 17:42:44

标签: c++ visual-studio

我在Visual Studio 2017中遇到了一个奇怪的错误。错误是

  

错误C3646' collisionSys':未知的覆盖说明符      
错误C4430缺少类型说明符 - 假设为int。注意:C ++没有       支持default-int

关于它的奇怪之处在于,当我构建解决方案时,我收到此错误但是当我删除collisionSys的声明并构建,然后重新声明collisionSys并再次构建时,它成功。虽然我在CollisionSystem.hpp进行了一些更改后再次发生了
我的代码如下:

CollisionSystem.hpp

 #ifndef COLLISION_SYSTEM__HPP
    #define COLLISION_SYSTEM__HPP

    #include <iostream>
    #include <vector>
    #include <SFML/Graphics.hpp>
    #include "../EntityManager.hpp"
    #include "../Entity.hpp"
    #include "../Components/Display.hpp"
    #include "../Components/Flags.hpp"
    #include "../Components/Movement.hpp"
    #include <Level.hpp>

    class Level;

    class CollisionSystem
    {
    public:
        CollisionSystem();
        void run(Level&, CameraSystem*, EntityManager*);
    private:
        static std::vector<std::shared_ptr<Entity>> m_Ents;
    };
#endif

CollisionSystem.cpp

#include <Systems/CollisionSystem.hpp>

std::vector<std::shared_ptr<Entity>> CollisionSystem::m_Ents;

CollisionSystem::CollisionSystem()
{

}

void CollisionSystem::run(Level& level, CameraSystem* cameraSys, 
EntityManager* EntMan)
{
    // Some collision detection here
}

LocalWorld.hpp

#ifndef LOCAL_WORLD__HPP
#define LOCAL_WORLD__HPP

#include <iostream>
#include <map>
#include <conio.h>
#include "GameState.hpp"
#include "StateMgr.hpp"
#include "Game.hpp" 
#include "TileMap.hpp"
#include "Level.hpp"
#include "ECS/Entity.hpp"
#include "ECS/Components/IncludeAllComponents.hpp"
#include "ECS/ResourceManager.hpp"
#include "ECS/EntityManager.hpp"
#include "ECS/Systems/IncludeAllSystems.hpp"

// Map Names
enum class MapName
{
    Map1
};

// Forward declaration
class Level;

class LocalWorld : public GameState
{
public:
    LocalWorld();
    ~LocalWorld();

    virtual void Pause();
    virtual void Resume();

    virtual void HandleEvents(sf::Event& eType);
    virtual void Update();
    virtual void Draw();
private:
    std::map<MapName, Level*> Maps;
    Level* activeLevel;

    ResourceManager ResMan;
    EntityManager EntMan;

    CameraSystem cameraSys;
    MovementSystem movementSys;
    ControlSystem controlSys;
    RenderSystem renderSys;
    CollisionSystem collisionSys;
};

#endif

错误在CollisionSystem collisionSys;

的第LocalWorld.hpp

IncludeAllSystems.hpp

#ifndef INCLUDE_ALL_SYSTEMS__HPP
#define INCLUDE_ALL_SYSTEMS__HPP

#include "CameraSystem.hpp"
#include "ControlSystem.hpp"
#include "MovementSystem.hpp"
#include "RenderSystem.hpp"
#include "CollisionSystem.hpp"

#endif

此处此文件包含CollisionSystem.hpp的所有系统 我查看了同样错误的其他问题,但仍无法修复。

编辑:

#include <Level.hpp>CollisionSystem.hpp移至CollisionSystem.cpp即可解决错误。任何人都能解释为什么会这样吗?

0 个答案:

没有答案