그래서 헤더 파일이 많은이 지오메트리 프로젝트를 작성해야합니다. 이 프로그램은 편집 할 때 나에게이 실수를합니다 : field 'p' has incomplete type
. 문제는 파일이 서로 종속되어 있다고 생각합니다. 이 헤더 파일은 다음과 같습니다필드에 불완전한 유형이 있습니까?
#ifndef POINT_H_INCLUDED
#define POINT_H_INCLUDED
#include "Line.h"
class Point
{
friend class Line;
friend class Vector;
double x;
double y;
double z;
public:
Point(double, double, double);
Point();
Point (Line& , Line&);
Point& operator=(Point&);
};
#endif // POINT_H_INCLUDED
#ifndef VECTOR_H_INCLUDED
#define VECTOR_H_INCLUDED
#include "Point.h"
class Point;
class Vector
{
friend class Line;
friend class Point;
double a;
double b;
double c;
public:
Vector(double,double,double);
Vector(Point&, Point&);
Vector();
Vector& operator=(Vector&);
};
#endif // VECTOR_H_INCLUDED
#ifndef LINE_H_INCLUDED
#define LINE_H_INCLUDED
#include "Point.h"
#include "Vector.h"
class Line
{
Point p;
Vector v;
public:
Line();
Line(Point& , Vector&);
Line(Point&,Point&);
};
#endif // LINE_H_INCLUDED
실수는 Point.h
파일에 제공됩니다. 나는 CodeBlocks에서 일하고있다.
빠른 노트 내가 Line에서 'Point * p'로 만들면 작동한다는 것을 알았지 만 그 이유는 무엇이며 어떻게 피할 수 있습니까? – user3719857
실제로 vector.h에 헤더를 포함시킨 후에'class Point; '를 전달하겠습니까? – alediaferia