C2065未声明标识符,但没有明显原因

时间:2019-06-18 19:07:57

标签: c++

错误输出:

C2065:“形状”:未声明的标识符|文件:Scene.h

我搜索了一个小时,但似乎无法解决此基本错误。 我失去了这一点。我敢肯定这是基本的东西,我将得到-1,但我真的看不到问题。

Scene.h

#pragma once

#include <vector>
#include <memory>
#include "Shape.h"

class Scene {
protected:
    std::vector<std::unique_ptr<Shape>> m_shape_ptrs; // <<<<< HERE
    //std::vector<std::shared_ptr<Light>> m_light_ptrs;

public:


    inline Shape& get_shape(int i) { return *m_shape_ptrs[i].get(); }
    std::pair<Shape*, float> intersect(const Ray& ray) const;
};

Shape.h

#pragma once

#include "Ray.h"
#include "Vector.h"
#include "Material.h"

class Shape {
public:
    Material material;

    virtual float intersect(const Ray& ray) const = 0;
    virtual Vec3f get_normal(const Vec3f& p) const = 0;
};

Material.h

#pragma once

#include "bitmap.hpp"
#include "Renderer.h"
#include "Shape.h"  // <<< HERE IT IS A CIRCULAR DEPENDENCY
#include "Ray.h"

class Material {
public:
    enum class TYPE : unsigned char
    {
        NULL_MATERIAL =  0,
        MIRROR,
        TRANSPARENT,
        PHONG,
        DIFFUSE
    };

    TYPE type;

    rgb_t get_color(const Shape& shape, const Ray& incident, const Renderer& renderer) const;
};

0 个答案:

没有答案