Your get() function will always just return the value of the root node. I think you mean to have return get(value, ...) in each of its if statements.
it worked, thank you :D
Nice, good luck with it from here!
In the get() function, instead of if{}... if{}... return it should be if{}... else if{}... else {return...}
This would be better style in my opinion, but by way of correctness it seems the more fundamental issue is "return" missing in the if... else if... blocks.
It's been a while since I did c++.
Does make_shared make a copy of the object and return a shared pointer to it, or does it read the memory location of the variable passed to it? The node is being created on the stack, which in this simple application will likely always be at the same memory location.
yup, it does that
this post was submitted on 13 Sep 2023
7 points (100.0% liked)
C++
1754 readers
4 users here now
The center for all discussion and news regarding C++.
Rules
- Respect instance rules.
- Don't be a jerk.
- Please keep all posts related to C++.
founded 1 year ago
MODERATORS