I'm sure this question has been asked before, but I can't seem to find it.
I have two classes, Vector and Point.
The files are as such (a bit repetitive):
vector.h:
#include <math.h>
#include <stdlib.h>
class Vector {
friend class Point;
public:
...
Vector(Point); // Line 16
vector.cpp:
#include <math.h>
#include <stdlib.h>
#include "vector.h"
...
Vector::Vector(Point point) { // Line 29
x = point.x;
y = point.y;
z = point.z;
}
point.cpp and point.h look mostly the same, except you swap vector with point in the definitions.
I include them as such:
#include "structures/vector.cpp"
#include "structures/point.cpp"
When I compile, I get this error:
structures/vector.h:16:17: error: field ‘Point’ has incomplete type
structures/vector.cpp:29:15: error: expected constructor, destructor, or type conversion before ‘(’ token
I think this error is saying that Point hasn't been declared yet, but when I declare it inside of vector.h by importing point.cpp, I get a huge pile of errors.
Could anyone shed some light on this problem?
Thank you!
Upon applying @ildjarn's suggestions, those errors went away and I am left with this single one:
structures/vector.h:16:18: error: expected ‘)’ before ‘const’
And the line:
Vector(Point const);
I define it like so in the .cpp file:
Vector::Vector(Point const &point) {