Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <string.h>
- using namespace std;
- struct contact {
- char name[100];
- char mobile_phone[20];
- char home_phone[20];
- char work_phone[20];
- };
- class phone_book {
- public:
- phone_book();
- phone_book(int max_number);
- phone_book(contact arr[], int arr_size);
- void AddContact(const char name[], const char mobile_phone[], const char home_phone[], const char work_phone[]) {
- if (contact_number == max_contact_number) {
- cout << "The contact cannot be added" << endl;
- return;
- }
- store[contact_number] = new contact{};
- strcpy(store[contact_number]->name, name);
- strcpy(store[contact_number]->mobile_phone, mobile_phone);
- strcpy(store[contact_number]->home_phone, home_phone);
- strcpy(store[contact_number]->work_phone, work_phone);
- contact_number++;
- }
- void DelContact(const char name[]);
- void FindContactName(const char name[]);
- void ShowAllContacts();
- ~phone_book();
- private:
- contact** store;
- int contact_number;
- int max_contact_number;
- };
- int main() { // для проверки функционала
- phone_book my_store; // для проверки конструктора по умолчанию
- //phone_book my_store(50); // для проверки конструктора для одного параметра
- //contact some_contacts[]{ {"Ivan", "+79111111111", "111111", "121212"}, {"Zhenya", "+79111111333", "111133", "121233"}}; // для проверки конструктора для двух параметров (закомментировать первые два добавления контакта)
- //phone_book my_store(some_contacts, 2); // для проверки конструктора для двух параметров
- my_store.AddContact("Ivan", "+79111111111", "111111", "121212");
- my_store.AddContact("Zhenya", "+79111111333", "111133", "121233");
- my_store.AddContact("Galya", "+79115511333", "166133", "127733");
- my_store.AddContact("Olya", "+79115511333", "166133", "127733");
- my_store.ShowAllContacts();
- my_store.DelContact("Zhenya");
- my_store.ShowAllContacts();
- my_store.AddContact("Zhenya", "+79111111333", "111133", "121233");
- my_store.FindContactName("Galya");
- }
Advertisement
Add Comment
Please, Sign In to add comment