0
我正在与多个类的CPP项目工作,并且我坚持了一段时间。我有颗粒类(头文件):未知覆盖说明符
#pragma once
#ifndef PARTICLE_H
#define PARTICLE_H
class Particle {
private:
vec3 pos; // <- here I get an error
vec3 dir;
float speed;
float size;
float amb[3];
public:
Particle();
Particle(bool sludge);
inline void setPosX(float posX);
inline void setPosY(float posY);
inline void setPosZ(float posZ);
inline void setSpeed(float speed);
inline void setSize(float size);
void setAmb(float amb0, float amb1, float amb2);
inline float getPosX();
inline float getPosY();
inline float getPosZ();
inline float getDirX();
inline float getDirY();
inline float getDirZ();
inline float getSpeed();
inline float getSize();
void renderParticle();
void renderSludge();
};
#endif
和CPP文件包括(为简单起见):
#include "stdafx.h"
#include "Tools.h"
#include "Particle.h"
#include "Player.h"
和工具类,它包含结构VEC 3:
#pragma once
#ifndef TOOLS_H
#define TOOLS_H
void distance(float posX1, float posY1, float posZ1, float radius1, float posX2, float posY2, float posZ2, float radius2);
int fibonacci(int num);
GLuint LoadObj(char * file);
GLuint LoadTexture(char * file, int magFilter, int minFilter);
void drawSphere(float r, int divisions);
void OnRender();
void OnReshape(int, int);
void OnKeyPress(unsigned char, int, int);
void OnKeyDown(unsigned char, int, int);
void OnKeyUp(unsigned char, int, int);
void OnTimer(int);
struct vec3 {
float x, y, z;
};
struct SFace {
int v[3];
int n[3];
int t[3];
};
#endif
我得到an:Error C3646 'pos': unknown override specifier
,我不明白为什么,因为Tools.h
似乎只包含一次,而Particle类应该知道Tools包含vec3
。我试图在Particle类的开头宣布struct vec3
,但它没有工作,我也做了一些没有任何效果的研究,所以我会感谢任何提示和帮助。
particle.h如何知道tools.h中的whats? – Eddge
你用C++ 11编译吗? 'override'关键字是C++ 11及更高版本的新手(尽管我没有看到它在您提供的代码中使用) – CoryKramer
您可能在“Particle.cpp”之外的文件中包含“Particle.h”。此时,可能不包括'Tools.h'。在'Particle.h'中包含你需要的头文件。将头部包含两次是没有问题的,特别是因为它似乎被'#include'后卫和'#pragma Once'两者所保护。 –