Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==50666==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000000048 at pc 0x5561c34e6202 bp 0x7fff375bc550 sp 0x7fff375bc540 READ of size 8 at 0x603000000048 thread T0 #0 0x5561c34e6201 in removeAll_helper /in/ex6.cpp:19 #1 0x5561c34e629d in BinaryTree::removeAll(TreeNode*) /in/ex6.cpp:26 #2 0x5561c34e6cba in BinaryTree::~BinaryTree() /in/ex6.cpp:63 #3 0x5561c34ea701 in test6() /in/compile/TestFunctions.cpp:125 #4 0x5561c34f8b74 in std::_Function_handler<void (), void (*)()>::_M_invoke(std::_Any_data const&) /usr/include/c++/7/bits/std_function.h:316 #5 0x5561c34f884e in std::function<void ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706 #6 0x5561c34e7975 in runTests(int) /in/compile/TestFunctions.cpp:19 #7 0x5561c34e5e20 in main /in/compile/test.cpp:13 #8 0x7fca56737c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) #9 0x5561c34e5b79 in _start (/out/package/t
Hints
Your answer may be identical to the JOJ answer in the first several lines.
However, the main problem you meet now is Runtime Error. And the exit code of your program is 1, which should be 0.
Please double check your code to solve this problem and try again.
Your Answer
Test 6: The sum of the copied tree is 30
JOJ Answer
Test 6: The sum of the copied tree is 30