It's only supposed to return the celebrities that contain the keyword the user searches for :'(. Instead it returns everything.

Eg. they enter the following:
Reba McIntire OK
George Clooney KY

Enter keyword: KY

It should only return George Clooney. Instead it returns all of them in the list.

Try it out and see. Boolsh# :'(

#include  <iostream> 
#include  <string> 
using  namespace  std; 

class Celeb
{ 
	private: 
		string name; //Name of celebrity folowed by decade they were born in, E.g. Reba McEntire 50s, 2nd e.g. Gene Hackman 30s
	
	public: 
		Celeb();	

		void setName(string);

		bool foundCelebs(string userKey) //;
			{
				
			if (name.find(userKey) != string::npos)  //::npos is required
				{
				return true;
				}
			else
				{
				return false;
				}
			}

		string getName(); 
};

Celeb::Celeb()
{
	name = "No person";
}

void Celeb::setName(string celebName)
{
	name = celebName;	
}

string Celeb::getName()   //; 
{
	return name;	
} 


void InputCelebs(Celeb * celbPtr, int size);

int main()
{
	Celeb search;

	string searchCelebs;

	int numCelebs;
	
	cout  <<  "How many celebs do you want to enter: " ; 
	cin  >>  numCelebs;
	
	Celeb * celebList;
	celebList = new Celeb[numCelebs];

	InputCelebs(celebList, numCelebs);  //User will then proceed to enter
										   //list of cities and their coordinates
	
	cout << "\nEnter a keyword, like the states abbreviation to search for, ";
	cout << "\n";
	
	cin >> searchCelebs;
	search.foundCelebs(searchCelebs);	 //--->>>> Call bool function

	bool found = false;
		
	for (int index = 0; index < numCelebs; index++)
		{
		
			if ( (search.foundCelebs(searchCelebs)) == false)  	//(!search.foundRegion(c_State_or_Province) will display "Your input did not match...." no matter what
			{	
				found = true;
				cout << index + 1 << ". " << celebList[index].getName() << "\n";
		
			}

		}
	
	if (found == false)
		{
			cout << "Your search produced nothing . " << endl;  //Must only execute once at the most (instead of number of celebs entered).
		}
	

	delete [] celebList;
	celebList = 0;

	system("pause");
	return 0;
}

void InputCelebs(Celeb * celebPtr, int size)
{
	string celeb_Name;  //Name of of celeb followed by state abbrev they were born in; e.g., Reba McEntire OK
		
	for (int index = 0; index < size; index++) 
	{

		cout << endl;
		cout << "Enter name of celebrity followed by a unique information,"; 
		cout << "\ntheir home state's abbreviation: ";
		cin.ignore();
		getline(cin, celeb_Name);
		celebPtr[index].setName(celeb_Name);

		cout << endl;		
	}

}

** I made a minor mistake, line 79 should be just; found = true;

Edit: sorry i didn't notice the edit button was under user name instead of below posts.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.