Recursive definitions

Started by
1 comment, last by tj963 22 years, 2 months ago
Hi, I have a struct that I am using for a tree structure. The problem is that when I try to declare pointers for parent, child, next and previous, vc gives me an error about recursive definitions. How can I work around this? struct TreeNode { TreeNode* Next; ... } Thanks, tj963 Edited by - tj963 on January 29, 2002 4:43:53 PM
tj963
Advertisement
Make sure they''re pointers. The definition you posted above will compile just fine; changing TreeNode *Next to TreeNode Next will result in the recursive definition error.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Problem with the "Treenode Next" example is that an infinite amount of memory would need to be allocated on object creation. This is not the case when using a pointer.

This topic is closed to new replies.

Advertisement