SlashOwnsU
Programmer
hi...I used to program in java - things were so nice with the packaging and all
now I'm new to C++ and having just a small problem with the include concept...
I'll make a classical example - let's say I have a Wheel class (in Wheel.h) and a Car class (Car.h)
I want the cars to have an array of wheels, thus I include Wheel.h in it...but let's say I want the wheel to know what car it's on - it has a Car ownedBy attribute...I'll have to include Car.h...mutual visibility between classes
what happens to the compiler is this:
- include Car.h from another file
- include Wheel.h from the Car.h header
- tries to create a Car instance, but can't because Car is undefined yet...it'll be defined when the compiler is done with Wheel.h
I tried to add
#ifndef WHEEL_H
#define WHEEL_H
...
#endif
in both files but it doesn't work
I don't know if you get the point, but basicly I want two classes from two different files to see eachother while avoiding multiple includes
now I'm new to C++ and having just a small problem with the include concept...
I'll make a classical example - let's say I have a Wheel class (in Wheel.h) and a Car class (Car.h)
I want the cars to have an array of wheels, thus I include Wheel.h in it...but let's say I want the wheel to know what car it's on - it has a Car ownedBy attribute...I'll have to include Car.h...mutual visibility between classes
what happens to the compiler is this:
- include Car.h from another file
- include Wheel.h from the Car.h header
- tries to create a Car instance, but can't because Car is undefined yet...it'll be defined when the compiler is done with Wheel.h
I tried to add
#ifndef WHEEL_H
#define WHEEL_H
...
#endif
in both files but it doesn't work
I don't know if you get the point, but basicly I want two classes from two different files to see eachother while avoiding multiple includes