I thought this looked familiar
http://www.cplusplus.com/forum/beginner/244659/ and it still has the same problems as the first.
You may have changed the order of some of the functions, but you still have the sane problems.
With the changes I talked about,and one that I did not say much about, I did manage to get the program working to a point until I found other problems.
The function "insertElement" worked like this:
1 2 3 4 5 6
|
void insertElement(int id, std::vector<std::string> args, TBST* tree) //to verify
{
int id1 = std::stoi(args[args.size() - 1]);
std::string name = join(args, 0); // <--- Changed to zero.
tree->insert(id1, name);
}
|
In your original code the subscript was 1. This accesses the second element of a three element vector. In my testing element 1 is the last name. Element 2 is the ID number. Accepting that the ID number is the last element of the vector this will change the last element of the vector into an "int" using the "stoi" function. And it removes the "segmentation fault" you had in your other post.
The other change I made is in the call to "join". Using 2 here through the function off and returns the wrong information. Accepting that the ID number is the last element of the vector then the first and second elements of the vector would be the first and last name that need to be joined together.
If you are going to send 2 to the join function then in the function definition change begin to end and set up the for loop as:
for (unsigned int i = 0; i < end; i++)
. You could also use "end" in the ternary condition.
BTW, posting the same code in different topics will not get you more help, but likely turn some people off. You have a complicated hard to follow program and not everyone will take the time to go through it. At one point I had to step through the program starting in main just to see where it went to find problems.
Hope that helps,
Andy