可能重复:
循环依赖/不完整类型
编写一个小 C++ 程序并感到困惑....
有 4 个类,2 个对这个错误很重要......
在第 13 行收到错误消息“字段 'dot' 的类型不完整”和“预期 ';' 在同一行中的“(”令牌”之前
错误似乎始于 Vector3.cpp,其中仅包含 Vector3.h 和空方法
删除了Normal3 Header中的include“Vector3.h”,以为会绕圈子...不太好...
一些想法?希望如此 :) 和 ty 寻求答案
这是我的两个重要课程:
#ifndef NORMAL3_H
#define NORMAL3_H
class Normal3 {
public:
double x, y, z;
Normal3 mul(Normal3 n);
Normal3 add(Normal3 n);
Normal3 dot(Vector3 v); //Line 13
Normal3(double x = 0, double y = 0, double z = 0)
: x(x), y(y), z(z)
{ }
};
#endif //NORMAL3_H
啊啊啊啊啊啊啊啊啊啊啊
#ifndef VECTOR3_H
#define VECTOR3_H
#include "Normal3.h"
class Vector3 {
public:
double x, y, z, magnitude;
Vector3 add(Vector3 v);
Vector3 add(Normal3 n);
Vector3 sub(Normal3 n);
Vector3 mul(double c);
double dot(Vector3 c);
double dot(Normal3 n);
Vector3 normalized();
Normal3 asNormal();
Vector3 refelctedOn(Normal3 n);
Vector3(double x = 0, double y = 0, double z = 0, double m = 0)
: x(x), y(y), z(z), magnitude(m)
{ }
};
#endif //VECTOR3_H