Hey, i need help with my phonebook directory, my code is fine and working perfectly, but i need help adding the name "Firstname, lastname". my code only accepts one name. and i also have to search the contact using lastname. i think i can use Map<String,List<String>> for that but i need help with adding two names.
//Checks whether the name exists or not
bool name_exists(string tname, string lname)
{
if (tname == name && lname == lastn)
return 1;
else
return 0;
}
//The contact object is initialized by valid values
bool add(string new_name, string new_lastn, string new_mob)
{
if (name == "")
{
name = new_name;
lastn = new_lastn;
mob = new_mob;
return 1; // Success
}
else
return 0; // Failure
}
//Edits the contact details
bool edit(string new_name, string new_lastn);
//Sets the contact details to default values
//That is, the contact details are thus erased
bool erase(string new_name, string new_lastn)
{
if (new_name == name && new_lastn == lastn)
{
name = "";
lastn = "";
mob = "";
return 1;
}
else
return 0;
}
};
*********************************************************
I updated your class a little ... Left the int main() for you to do. For the most part all you have to do is update the main to accept the last name etc...
1. There is no reason to have stdlib.h .. it's the same as using namespace std;
2. All you had to is add "last name" and implement it every time your ask for first name.
btw .... You should optimize your code and fix your class format if you're in the mood..... anyway good luck and I hope this helps..
thank you! i did and it's giving me error at //Check whether name exists i try to put temp_lastn but it's still giving me error. unfortunately my pc doesnt allow me to view what my error is. and i used the #include stdlib for "cls" (clear screen without system)