I need your help to solve a problem. Problem is to create a dynamic tree in memory.
I have a node with 2 field 1. Self Record Number and 2. Parent Record Number
I need to create a hierarchy (Tree) based on above information. Any node can come in any sequence. There is no rule defined for hirerchy.
How to set the node at run time so that I can create a correct child-parent hierarchy?
The "parent" should point to the parent and the "self" should point to the sibling.
But it is a very poor implementation, difficult to walk and maintain (who are the children of a given parent? you should keep a list of the "world" to scan!).
Hierarchies normally requires more pointers:
- to the parent
- to the first child (and eventually to the last)
- to the next sibling (and eventually the previous)
The CString does not only contain a pointer to a character array, but also more information such as allocation size and length of current data. If you use a CString as an argument you will push all that to the stack, when in fact you only want the pointer to the character array on the stack, as described by the format specifiers to CString::Format(). You will simply mess up the arguments/stack. Do the conversion I suggested in the answer above to avoid this.
This is one reason to avoid variable arguments whenever possible. The compiler cannot perform type checks.
I am using visual studio 2010 and sometimes when i try to create a variable using add member variable wizard, it is not created. Try again and again and it is not created make a new dialog box and a new control then it is created.
The wizards are generally unreliable, they're buggy, specially if you mess with any of the code they've generated (and the text comments/tags it inserts for itself). My recommendation, learn to do everything without wizards. It'll make you an overall better developer and will keep you from relying on something that works part of the time.