my code is something like this,i have created the list containing the following names and their address. now i need to search the list by giving a string,if the string matches the any entry in the list,then i should be able to print the that particular entry totally
please help me on this
class Contact
{
public:
Contact(const char *Name, const char *Address): _first(Name), _last(Address)
{ }
void print() const { cout << _first << " " << _last << endl; }
private:
string _first;
string _last;
};
typedef list<Contact> LIST;//we define PERSONLIST
main()
{
// Create an empty list.
LIST myFriends;
myFriends.push_back(Contact("charan","knagar"));
myFriends.push_back(Contact("Hari","cvrnagar"));
myFriends.push_back(Contact("chethan","rnagar"));
cout << "A list of Contacts:" << endl;// Printing the list.
for(LIST::const_iterator i = myFriends.begin(); i != myFriends.end(); i++)
{
(*i).print();
}
return 0;
}