I have a class of a tree B that has a search method, the search method should return a reference to the value associated with the searched key, so the user can change it if you want, this is a pair used in the tree :
template<class Key, class Value>
class Pair{
public:
Pair(){
key = Key();
value = Value();
}
Pair(Key key, Value value){
this->key = key;
this->value = value;
}
Key key;
Value value;
};
The problem is that I do not know what to do when the search does not find anything. So what I want is a method that can return a reference to something and somehow inform if the value is valid or not, there are some ways to do this, I'll list the ones I've found and why I do not want to use them: / p>
If you can tell me how to solve this, I thank you.