所以这显然不是真正的错误,但是我不知道实际的错误是什么,因为症状是如此模糊。我将仅在此处包括文件,你们告诉我您认为可能会导致未声明的标识符错误的位置和内容。

system.h(66): error C2065: 'EntityManager' : undeclared identifier

系统

/*******************************************************************************
filename: System.h

Author:

Date: November 13, 2010

********************************************************************************/


#ifndef SYSTEM_H
#define SYSTEM_H

#include <string>
#include <memory>

//The interfaces for the framework elements.
#include "I_OS.h"
#include "I_Graphics.h"

//The derived interface elements tailored to the platform.
#include "Windows_module.h"
#include "D3D11_module.h"
#include "EntityManager.h"

// ** AUTHOR NOTE ** temporary until ini file reading is implemented
#define FULL_SCREEN false


/*******************************************************************************
Purpose:
This will be the central object that is responsible for containing and
systematically initializing, updating per frame, and shutting down ALL the objects
responsible for the various internal workings of the framework. This will also
serve as the nexus for all external entities to retrieve data, interface with engine
elements, as well as interfacing between eachother.
********************************************************************************/

class System
{
public:

    /* All framework elements and interfaces contain an Initialization context to be
    created outside, filled out, and passed into the Initalize function. This is to
    maintain polymorphic similar function declarations, while still having variable
    parameters */

    class InitializeContext
    {
    public:
        HINSTANCE hinstance;
    };

    System();
    ~System();

    bool Initialize(InitializeContext &);
    void Run();
    void Shutdown();

public:

    //pointer declarations of interface types for each framework element
    std::shared_ptr<I_OS> m_os;
    std::shared_ptr<I_Graphics> m_graphics;
    std::shared_ptr<EntityManager> m_EntityManager;
};


/* This will be the global pointer that all entities will use to access the
public interface pointers to the entire framework.

** AUTHOR NOTE ** : all entities should refer to the interfaces, and non platform
specific elements to maintain crossplatform compatibility, (if it can be avoided)*/
extern std::shared_ptr<System> g_System;

#endif


EntityManager.h

/*******************************************************************************
filename: EntityManager.h

Author:

Date: October 27, 2011

********************************************************************************/

#ifndef ENTITY_MANAGER_H
#define ENTITY_MANAGER_H

#include <vector>
#include <map>
#include <fstream>
#include <memory>
#include "EntityBase.h"
#include "EntityList.h"

/*******************************************************************************
Purpose:
This wil be the object responsible for managing and updating all the various Entities
currently rendered in a scene. It reads from a scene file and dynamically creates instances
of the objects listed to be stored in a vector. these objects can be accessed individually
by either index or unique string identifier, or you can obtain a vector that contains
objects of the same class type.
********************************************************************************/
class EntityManager
{
public:
    bool Initialize();
    bool Frame();
    void Shutdown();

private:
    BaseFactory m_factory;
    std::vector <std::shared_ptr<BaseEntity> > m_EntityList;
    std::map<std::string, std::shared_ptr<BaseEntity> > m_EntityByNameList;
    std::map<std::string, std::vector<std::shared_ptr<BaseEntity> > > m_EntityByClassList;
};

#endif


那么,导致EntityManager未被声明有什么问题吗?这是输出中的唯一错误。认为您需要更多的文件,我将包括它们。

最佳答案

这通常是由循环包含头文件引起的。在您的情况下,EntityBase.hEntityList.h包含System.h。解决此问题的最简单方法是从#include "EntityManager.h"中删除​​System.h并在class EntityManager;中转发声明system.h。请注意,您需要在#include "EntityManager.h"中执行system.cpp

关于c++ - 错误C2056:未声明的标识符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11304432/

10-11 20:45