Error C2079 Object::color uses undefined struct 'Vector'

closed account (2NywAqkS)
I have a header file for a vector that looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef VECTOR_H
#define VECTOR_H

#include "main.h"

struct Vector
{
	double x;
	double y;
	double z;

	// Funtions
	double Dot(Vector);
	Vector Cross(Vector);
	double Magnitude();
	Vector Normal();
	Vector operator + (Vector);
	Vector operator - (Vector);
	Vector operator * (Vector);
	Vector operator * (double);
	bool operator == (Vector);

	Vector();
	Vector(double x, double y, double z);
};

#endif 


However in another header I want some vector members like this
1
2
3
4
5
6
7
8
9
10
11
//// object.h
struct Vector; // If I don't define Vector here a get a bunch more errors

struct Object
{
	Vector color;

	virtual Intersection Intersect(Ray l);
	virtual bool operator == (Object);
	Object();
};


This gives my the error in the title. How do I get around this problem without having to use pointers? and preferably without having to redefine vector in every header?

Thanks,
Rowan.
You should include the header file with the definition of Vector in object.h
Last edited on
closed account (2NywAqkS)
Doesn't help :(

in main.h both vector.h and object and included
1
2
#include "vector.h"
#include "objects.h" 
Show how you include all your haders in your modules.
Dont include main.h in vector:

vector.h - no includes
vector.cpp - include vector.h

object.h - include vector.h
object.cpp - include object.h

main.h - include object.h (optionally vector.h)
main.cpp - include main.h
Topic archived. No new replies allowed.