Possible Duplicate:
Are C++ recursive type definitions possible, in particular can I put a vector<T> within the definition of T ?
I was looking through some code recently and noticed a data structure similar to the following:
class TreeNode {
std::vector<TreeNode> subNodes;
};
As you can see, the container is instantiated with TreeNode before TreeNode has been defined. The code compiles under both GCC and MSVC, but I remember seeing something saying that this is not guaranteed behaviour. Unfortunately I can't find anything in the standard discussing this at all.
How are such containers able to be implemented? Is this behaviour guaranteed by the standard? If this is not guaranteed by the standard, what alternatives do I have to this design?