-
New Error For Me, Thanks for any help
Heyas,
I am attempting to get my tree setup to receive the following constructors...
Tree(void);
Tree(Tree *, Tree *);
Tree(unum,uchar);
When I compile I get these errors....
tree.cpp: In function `int main()':
tree.cpp:252: initializer list being treated as compound expression
tree.cpp:252: invalid conversion from `uchar' to `Tree*'
tree.cpp:253: initializer list being treated as compound expression
tree.cpp:253: invalid conversion from `uchar' to `Tree*'
tree.cpp:254: initializer list being treated as compound expression
tree.cpp:254: warning: unused variable `Tree*r'
This is the only initializer list I use....
Node(unum d = 0, uchar l = '\0', Tree * ln = NULL, Tree *
rn = NULL) :
data(d),letter(l),left(ln),right(rn)
{};
This is the main function(test code) that I am working on.
int main()
{
unum num = 5;
uchar let = 's';
Tree * s(num, let);
Tree * t(num, let);
Tree * r(s,t);
//cout << r->getdata() << endl;
return 0;
}
Any ideas are appreciated and an explanation of what the error actually is as I have not seen this one before and a better understanding of what the compiler is yelling about would be valuable in the long term.
Tim Walter
-
You have two options. Create a Tree on the stack or on the heap.
On the stack: Tree tree(num, let);
On the heap: Tree *tree = new Tree(num, let);
You are trying to do a mix of it =)
-
Popular pages
Recent additions