Class

I have this code. I want to print "FOUND" if the name is found and "NOT FOUND" if the name don't exist. Can someone help me?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  void Fractory::FindByName()
{
	string name;
	cout << "enter name:"; cin.ignore();
	getline(cin, name);
	int flag = 0;
	for (int i = 0; i < emp.size(); i++)
	{
		if (name.compare(nv1[i]->getName()) == 0)
		{
			emp[i]->Print();
		}
	}
}
Last edited on
Many undeclared variables and functions. Please post whole code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  void Fractory::FindByName()
{
	string name;
	cout << "enter name:"; cin.ignore();
	getline(cin, name);
	bool found = false;
	for (int i = 0; i < emp.size(); i++)
	{
		if (name.compare(nv1[i]->getName()) == 0)
		{
			found = true;
			cout << "Found " << name << endl;
			emp[i]->Print();
		}
	}
	if (!found)
		cout << "NOT Found!" << endl;
}
Topic archived. No new replies allowed.