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

Apr 1, 2013 at 1:27pm
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.
Apr 1, 2013 at 1:30pm
You should include the header file with the definition of Vector in object.h
Last edited on Apr 1, 2013 at 1:31pm
Apr 1, 2013 at 1:33pm
closed account (2NywAqkS)
Doesn't help :(

in main.h both vector.h and object and included
1
2
#include "vector.h"
#include "objects.h" 
Apr 1, 2013 at 1:39pm
Show how you include all your haders in your modules.
Apr 1, 2013 at 1:41pm
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.