I have been trying to make use of operator overloading in my program, however I have been running into issues.
Basically, I have a binary search tree and I am trying to get it so that if you enter something like "tree = tree + 7", it will add the key value 7 as a node. I have been experimenting with the code to do this:
struct addToTree {
string treeName;
int value;
string output;
string operator+(string addToTree &lhs, int addToTree &rhs) {
addToTree temp;
temp.output = lhs.treeName + to_string(rhs.value);
return temp.output;
}
};
At the moment, I am just trying to get it to take the name of the tree, and add to that the value that the user enters to add to the tree.
I am currently getting a number of errors and I don't think my code is even close to how it should be so if anyone could give me advice to show me what I should be doing, that would be much appreciated.