-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemporary.cpp
More file actions
57 lines (46 loc) · 1.05 KB
/
temporary.cpp
File metadata and controls
57 lines (46 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <list>
using namespace std;
class Employee
{
public:
Employee (const char *pName):name(pName) {}
Employee(string sName, string sAddress):name(sName),address(sAddress)
{}
string name;
string address;
};
// Lets figure out the temporaries from this function
static string
GetAddrFromName (list<Employee> l, string name)
{
for( list<Employee>::iterator i = l.begin(); i != l.end(); i++ )
{
if( (*i).name == name )
{
return (*i).address;
}
}
return "";
}
static void
printEmployeeDetails (Employee emp)
{
cout << "Name - " << emp.name << endl;
cout << "Address - " << emp.address << endl;
}
int
main ()
{
list<Employee> empList;
Employee emp("Kiran", "Bangalore");
string sFind = "Koushik";
empList.push_back(emp);
Employee emp1("Koushik","Provo");
empList.push_back (emp1);
cout << "Finding address of " << sFind << endl;
cout << "Found the address " << GetAddrFromName (empList, sFind) << endl;
// How about GetAddrFromName (empList, "Koushik");
printEmployeeDetails ("Koushik");
return 0;
}