I'm not too familiar with exception handling so could someone help me with this problem?? So for this program, incase of a non-existing key in the std::map, I want to throw something but I dont know what.
the map key if it exists will be a phone number (string), but if it doesn't exist what would it be??
class SmartCarrier{
private:
string carrier_name_;
map<string,vector<Message*>> accounts_map;
public:
Search();
}
void phone::Search{
string phone_number;
map<string,vector<Message*>>::iterator iter;
cout << "Enter a phone number: ";
getline(cin,phone_number);
try{
iter = phone_map.find(phone_number);
if (iter ==phone_map.end()) {
//Incase of a non-existing phone number what do I throw?
throw iter;
}
}
catch(/*iter ??? what should the block catch as a value?*/){
cout << "Phone number not found." << endl;
}