我试图在我的 Photon.h 中包含头文件,以创建Photon
类。但是,这告诉我无法解析类型(我尝试包括的头文件中的类型)。这是我的代码:
#ifndef PHOTON_H_
#define PHOTON_H_
#include "vertex.h"
#include "vector.h"
#include "colour.h"
#include "ray.h"
#include "hit.h"
#include "point_light.h"
//#include "photon.h"
class Photon {
public:
Vertex start_pt;
Vertex position; //position of intersection
Vector direction;
Colour intensity;
float w; //for the weight for russian roulette
float BRDF;
Colour BRDF_s, BRDF_d;
bool shadow;
bool reflected;
bool absorbed;
bool transmitted;
Photon();
Photon(PointLight L); //generate a photon at the light source
void ray(Ray &r); //generates a ray to model the photon
void g_russian_roulette(Hit h, int w, int &new_w);
void c_russian_roulette(Hit h, int w, int &new_w);
void outcomes(); //unsure on this one - delete
void main(); //delete
};
#endif /* PHOTON_H_ */
类型Vertex
,Vector
,Colour
,Hit
,Ray
和PointLight
无法解析,即使它们以前已经起作用在不同的文件中。尝试运行主文件时收到以下错误消息:
x86_64体系结构的未定义符号:
“光子:: c_russian_roulette(Hit,int,int&)”,引用自: cc4cUJsn.o中的c_trace(Photon *,Object *,int,std :: vector>)
“光子:: g_russian_roulette(Hit,int,int&)”,引用自: g_trace(Photon *,Object *,PointLight *,int,std :: vector>)在 cc4cUJsn.o“ Photon :: ray(Ray&)”,引用自: g_trace(Photon *,Object *,PointLight *,int,std :: vector>)在 cc4cUJsn.o cc4cUJsn.o中的c_trace(Photon *,Object *,int,std :: vector>)
“光子::光子(PointLight)”,引用自: g_photon_map(Object *,PointLight *,int,std :: vector>)在 cc4cUJsn.o c_photon_map(Object *,PointLight *,int,std :: vector>)在 cc4cUJsn.o“ Photon :: Photon()”,引用自: cc4cUJsn.o中的_main ld:找不到体系结构x86_64 collect2的符号:错误:ld返回1退出状态
如果有人对如何解决此问题有任何建议,将不胜感激。我觉得自己缺少了一些小东西,我对C ++还是很陌生,而且总体上我没有太多的编程技能。