COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
cp9.1list.cpp File Reference
#include <iostream>
#include <string>
#include <list>
Include dependency graph for cp9.1list.cpp:

Go to the source code of this file.

Classes

class  student
 

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void )

Definition at line 13 of file cp9.1list.cpp.

13 {
14 string input;
15 list<student> record;
16 while (true) {
17 cin >> input;
18 student temp;
19 if (input == "Add") {
20 cin >> temp.name >> temp.major >> temp.number;
21 record.push_back(temp);
22 cout << "Added Successfully" << endl;
23 }
24 else if (input == "Search") {
25 list<student>::iterator itr;
26 bool found = false;
27 cin >> temp.name >> temp.major;
28 for (itr = record.begin(); itr != record.end(); itr++) {
29 if (itr->name == temp.name && itr->major == temp.major) {
30 cout << "Student number:" << itr->number << endl;
31 found = true;
32 break;
33 }
34 }
35 if (!found) {
36 cout << "No Record found" << endl;
37 }
38 }
39 else if (input == "Quit") {
40 cout << "Bye" << endl;
41 break;
42 }
43 }
44}
string name
Definition cp9.1list.cpp:8
string major
Definition cp9.1list.cpp:9
int number
Definition cp9.1list.cpp:10

References student::major, student::name, and student::number.