I need to declare two stacks of a struct inside of it's own struct declaration. I know I could do this operation with an array as long as I reference it with a pointer inside the struct (i.e. FA *goingTo[30];
would give me an array of 30 FA
s). Is there a similar way to reference a stack?
typedef struct FA
{
std::stack<FA> goingTo;
std::stack<FA> comingFrom;
};
The stack objects that you are defining in the struct would themselves contain (possibly) multiple instances of the struct, each instance containing its own stacks which again contain more of the structs. So if you think about it, this is an infinite chain of containment. You can modify the definition (and the usage) to contain stacks of pointers to FA*. This would solve the problem.
typedef struct FA {
std::stack<FA*> goingTo;
std::stack<FA*> comingFrom;
};