@ravel: From Gearbox.h you must include Car.h.
Anyways, if you want to add components to a car, you should follow your older route, so, ignore what I wrote above.
Just make sure to declare bodies in .cpp and functions/variables in .h.
> As for the code, its huge and I'm not going to post the whole code.
Then try to reproduce your problem in an smaller program. It should be obvious that you need to paste the errors that correspond to the smaller testcase http://www.eelis.net/iso-c++/testcase.xhtml (6)
> Now I got a new issue, the dll I compiled crashed while trying to run it.
probably your `car' pointer is invalid. Hard to say without seeing the code for the constructors and how it is invoked. http://www.cplusplus.com/forum/general/112111/
Your engine class is defined and accessible. This is not a compilation problem.
It's a logic problem. You are creating a pointer, then trying to get the data it points to -- but you never tell it to point to anything.
Example:
1 2 3 4 5 6 7
std::string* foo; // a pointer to a string
// but note that we never actually assign it, so it is a bad/uninitialized pointer.
cout << foo->length(); // <- prints the length of whatever string we are pointing to
// But again! What string? We never say! We have a pointer that points to nothing
// so how can the computer know the length of a string which doesn't exist?
So you have a pointer in your code somewhere. And you are accessing the object it points to. But you never actually made it point to anything. That's why this is crashing.
You probably forgot to do this part:
I wrote:
The MyClass object will then need to tell the SubClass who the owner is (ie: it will need to provide that pointer. You can probably do this in the MyClass constructor:
1 2 3 4
MyClass::MyClass()
{
mySubClass.owner = this; // tell the sub class that 'this' is the owner
}