I am trying to code a Binary tree and am currently trying to get an 'inorder' function to work which takes in a binary tree containing integers and outputs the binary tree to a string in numerical order. However when I try to concatenate the integer to the end of the string I am receiving the error message "Error C2440: 'type cast' : cannot convert from 'int' to 'std::string'.
The code for the function is as follows:
void _inorder(node *tree, string &str)
{
if (tree != NULL)
{
_inorder(tree->left, str);
str = str + (string)(tree->data);
_inorder(tree->right, str);
}
cout << str << endl;
}