Let's go over a few things:
1) In C++, Trees are implemented with pointers. Without them, there's no tree structure
[1].
2) C++ doesn't have a garbage collection system. Therefore, memory allocated with
new must be deleted with
delete[2]. Failure to do so will cause resource leaks.
3)
current doesn't exist in any scope within your code. You need to declare identifiers before you use them. What you're after is
this[3].
4)
troutguy wrote: |
---|
Tree newTree(); |
This is called
the most vexing parse[4]. It gives the impression that the programmer is declaring a variable, but in fact, it's creating a function prototype. As a result, one would use the function prototype as a variable, and would consequently receive errors.
References:
[1] http://www.codeproject.com/Articles/24684/How-to-create-Linked-list-using-C-C
[2] http://www.cplusplus.com/reference/std/new/operator%20delete/
[3] http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr035.htm
[4] http://en.wikipedia.org/wiki/Most_vexing_parse
You seemed to have missed heaps of information. I recommend going back and studying classes and DMA again.
Wazzak