c++ - C2065 未声明标识符但没有明显原因
问题描述
错误输出:
C2065:“形状”:未声明的标识符 | 文件:Scene.h
我搜索了一个小时,似乎无法解决这个基本错误。我失去了这一点。我确定这是基本的东西,我会得到-1,但我真的看不出问题。
场景.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;
};
形状.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;
};
材料.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;
};
解决方案
推荐阅读
- objective-c - 有什么方法可以在 macOS 上获取系统定义目录的本地化显示名称?
- android - 片段堆栈管理
- python-3.x - python tkinter中的动态表单小部件交互
- java - 使用 junit 在 Gradle 中运行集成测试
- c# - 如何在 ASP.NET Core 中解析移动视图
- sql - 有没有办法通过 SQL 获取没有扩展名的文件名?
- git-log - 我正在尝试从 Grgit 日志中获取提交正文,这可能吗?
- python - Python 点击在帮助页面中显示模块版本
- c# - 实现相互使用的类型化接口的问题
- arrays - 如何在 ngFor 中将数组拆分为四个项目?