0% found this document useful (0 votes)
21 views4 pages

Abdullah Anwar 1171 Project

The document contains a C++ program that defines a Contact class for managing contact information, including name, phone, and email. It also includes a ContactManager class that allows users to add, display, and search for contacts. The main function provides a simple text-based menu for interacting with the contact management system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views4 pages

Abdullah Anwar 1171 Project

The document contains a C++ program that defines a Contact class for managing contact information, including name, phone, and email. It also includes a ContactManager class that allows users to add, display, and search for contacts. The main function provides a simple text-based menu for interacting with the contact management system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <iostream>

#include <vector>

#include <string>

using namespace std;

class Contact {

private:

string name;

string phone;

string email;

public:

Contact(string n, string p, string e) {

name = n;

phone = p;

email = e;

string getName() {

return name;

void display() {

cout << "Name: " << name << endl;

cout << "Phone: " << phone << endl;

cout << "Email: " << email << endl;

};
class ContactManager {

private:

vector<Contact> contacts;

public:

void addContact(string name, string phone, string email) {

contacts.push_back(Contact(name, phone, email));

void displayAll() {

for (auto& c : contacts) {

[Link]();

cout << "------------------" << endl;

void searchContact(string name) {

bool found = false;

for (auto& c : contacts) {

if ([Link]() == name) {

[Link]();

found = true;

break;

if (!found) {

cout << "Contact not found." << endl;

}
};

int main() {

ContactManager cm;

int choice;

string name, phone, email;

do {

cout << "1. Add Contact\n2. Display All\n3. Search Contact\n4. Exit\nChoice: ";

cin >> choice;

[Link]();

if (choice == 1) {

cout << "Enter Name: ";

getline(cin, name);

cout << "Enter Phone: ";

getline(cin, phone);

cout << "Enter Email: ";

getline(cin, email);

[Link](name, phone, email);

} else if (choice == 2) {

[Link]();

} else if (choice == 3) {

cout << "Enter Name to Search: ";

getline(cin, name);

[Link](name);

} while (choice != 4);


return 0;

You might also like