Having trouble with some code, does anyone know how to do this:
class Location contains a vector of pointers to Boxes. struct Box contains a Location for that Box.
Whichever is declared first does not have the definition of the other. Any ideas?
Having trouble with some code, does anyone know how to do this:
class Location contains a vector of pointers to Boxes. struct Box contains a Location for that Box.
Whichever is declared first does not have the definition of the other. Any ideas?
Does this help?I'm not real heavy on STL, so this may not be "correct," but it compiles.Code:#include <iostream> #include <vector> using namespace std; typedef struct BOX_STRUCT { int Length, Width, Height, Volume; vector<BOX_STRUCT>::iterator BoxLocation; // vector iterator to self } Box; class Location { public: Location() {} ~Location() {} vector<Box> ListOfBoxes; }; int main() { Location MyBoxes; Box CurrentBox; MyBoxes.ListOfBoxes.push_back(CurrentBox); // Do your thing... return 0; }
Last edited by fletch; 08-18-2002 at 09:11 PM.
"Logic is the art of going wrong with confidence."
Morris Kline
>>Chicken or the Egg problem...
The egg came first. But that's OT
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]