C++ 如果我包含一些头文件,我的程序就会出现很多缺失、语法和未声明的错误。(C+;+;)

C++ 如果我包含一些头文件,我的程序就会出现很多缺失、语法和未声明的错误。(C+;+;),c++,header,include,syntax-error,undeclared-identifier,C++,Header,Include,Syntax Error,Undeclared Identifier,我已经更改了我的一个类,添加了一个方法和一些include,在这样做之后,我得到了很多未定义或缺少的错误,这些错误在以前都没有问题,并且工作得很好。 这是我得到错误的头文件: 资产装载机 #ifndef LS_ASSETLOADER_H #define LS_ASSETLOADER_H #include <assimp/Importer.hpp> #include <assimp/scene.h> #include <assimp/postprocess.h>

我已经更改了我的一个类,添加了一个方法和一些include,在这样做之后,我得到了很多未定义或缺少的错误,这些错误在以前都没有问题,并且工作得很好。
这是我得到错误的头文件:

资产装载机

#ifndef LS_ASSETLOADER_H
#define LS_ASSETLOADER_H
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <assimp/types.h>

#include <glm/glm.hpp>
#include <vector>

//these are the headers that give me problems
//#include "scene.h" 
//#include "model.h"



//the 2 methods below are commented so i don't get errors for missing Scene
class AssetLoader {
    //void importScene(aiNode* node, ls::Scene* scene, const aiScene* aScene);

public:
    bool loadMesh(
        const char* path,
        std::vector<glm::vec3>* vertices,
        std::vector<glm::vec3>* normals,
        std::vector<glm::vec2>* uvs
    );

//  bool loadScene(const char* path, ls::Scene* scene);
};

#endif

看起来您已在
mesh.h
中包含
model.h

您需要在model.h中向前声明
Mesh

class Mesh;
class Model {

scene.h
model.h
间接地
#包括
assetloader.h
头吗?我包括了mesh.h头,似乎我在那里包括assetloader.h,然后是model.h包括mesh.h,这是问题吗?确实是的。这是所有解释(第一个问题/答案)感谢链接,作出转发声明似乎解决了问题,但现在我得到了另一条消息(可能我不太明白在哪里使用它)。我删除了mesh.h中的#include“assetLoader.h”,并添加了类assetLoader;但现在我得到了以下消息:
assetloader.obj:error LNK2019:unresolved外部符号“public:u thiscall Mesh::Mesh(void)”(??0Mesh@@QAE@XZ)函数“private:void\uu thiscall AssetLoader::importScene(struct aiNode*,class Scene*,struct aiScene const*)中引用(?importScene@AssetLoader@@AAEXPAUaiNode@@pavsecene@@PBUaiScene@@@Z)
好像程序不知道网格,即使我将其包含在assetloader文件中
#ifndef LS_MODEL_H
#define LS_MODEL_H
#include "mesh.h"
#include "material.h"
#include "renderer.h"
#include <glm/glm.hpp>

class Model {

    Mesh* _mesh;
    Material* _material;
    Renderer* _renderer;

    glm::mat4 _transform;

public:
    Model(Mesh* mesh, Material* material);
    Renderer* renderer() const;
    glm::mat4 transform() const;

    void setPosition(glm::vec3 position);
    void translate(glm::vec3 translation);
    void scale(glm::vec3 factor);
    void setRotation(glm::vec3 axis, float angle);
};

#endif
#ifndef LS_MESH_H
#define LS_MESH_H
#include <vector>
#include <glm/glm.hpp>
#include "assetloader.h"
#include "texture2D.h"

class Mesh {
    std::vector<glm::vec3> _vertices;
    std::vector<glm::vec3> _normals;
    std::vector<glm::vec2> _uvs;

public:
    Mesh(const char* path);
    Mesh();

    int numVertices() const;
    std::vector<glm::vec3> vertices() const;
    void setVertices(std::vector<glm::vec3> vertices);
    std::vector<glm::vec2> uvs() const;
    void setUVs(std::vector<glm::vec2> uvs);
    void setNormals(std::vector<glm::vec3> normals);
    std::vector<glm::vec3> normals() const;


};

#endif
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(10): error C2143: syntax error : missing ';' before '*'
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(12): error C2143: syntax error : missing ';' before '*'
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(17): error C2061: syntax error : identifier 'Mesh'
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(18): error C2143: syntax error : missing ';' before '*'
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\chip\documents\visual studio 2010\projects\letsstart\letsstart\model.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int  
class Mesh;
class Model {