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?
Printable View
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;
}
>>Chicken or the Egg problem...
The egg came first. But that's OT ;)