STL Based Telephone Book

Understand the usage of vector collection for storing user-defined Person class objects.

We'll cover the following

Problem

Write a program using STL to maintain a telephone book containing names and telephone numbers. It should be possible to search the telephone book either using a name or using a telephone number.

Sample run

Here’s what you should see when you run the program.

1. View Phone Book
2. Search by name
3. Search by number
0. Exit
Enter your choice
1
Nimish 2534123
Anmol 982301
Shubham 789635

1. View Phone Book
2. Search by name
3. Search by number
0. Exit
Enter your choice
2
Enter name: 
Dinesh
Search Results: 
No matching entry 

1. View Phone Book
2. Search by name
3. Search by number
0. Exit
Enter your choice
2
Enter name: 
Anmol
Search Results: 
Anmol 982301

1. View Phone Book
2. Search by name
3. Search by number
0. Exit
Enter your choice
3
Enter phone number: 
123456
Search Results: 
No matching entry 

1. View Phone Book
2. Search by name
3. Search by number
0. Exit
Enter your choice
3
Enter phone number: 
789635
Search Results: 
Shubham 789635

1. View Phone Book
2. Search by name
3. Search by number
0. Exit
Enter your choice
0

Coding solution

Here is a solution to the problem above.

Get hands-on with 1200+ tech skills courses.