Having big problems with classes
I'm making a heavily object oriented text based RPG as a refinement of my skills (I've posted a lot on the game and C++ boards because of problems I've had).
I've been neatening up my code and making it easy to manipulate before I put in more code. However, it seems I've gotten into a problem with including headers again.
Here's the basic structure of my code and what references what.
- Has a location (a Room pointer)
- Has an inventory (an Inventory pointer)
- Has a destination (a Destination pointer)
- The destination is used if the item can be the target of a "go" command
- Has a "next" item when in an inventory (an Item pointer)
- Has an array of exits (Room pointers)
- Has items on the ground (Item pointers)
- Has a head and tail (pointers to Items)
I'm trying to use the Destination class because I don't want items to have pointers to rooms.
- Has "exits" that are accessed with the "go" command (pointers to Rooms)
Here's my problem. When I try to #include the header for Destination in the Item class, I get an error in the Room class that it doesn't understand what an Inventory is. Not only that, it even doesn't know what an Item is.
In file included from Destination.h
-here it gives a syntax error on the line where I declare the Inventory for the Room class
I'm starting to really hate #include. Isn't there some way to tell my code "Shut up. These classes exist, you idiot. Look first before you tell me they don't."? It seems that while following all of my #includes, the compiler gets confused.