fix: search() call the destructor of phone_book

This commit is contained in:
Camille Chauvet 2023-05-22 17:08:28 +00:00
parent dce65dcb84
commit 7bc9220a7a

View File

@ -3,6 +3,7 @@
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <bits/stdc++.h> #include <bits/stdc++.h>
#include <ostream>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include "../include/PhoneBook.hpp" #include "../include/PhoneBook.hpp"
@ -34,10 +35,9 @@ Contact* read_contact()
return (NULL); return (NULL);
return (new Contact(first_name, last_name, nickname, phone_number, darkest_secret)); return (new Contact(first_name, last_name, nickname, phone_number, darkest_secret));
} }
Contact* search(PhoneBook phone_book) Contact* search(PhoneBook &phone_book)
{ {
int index; int index;
std::string index_str; std::string index_str;
@ -60,7 +60,6 @@ int main()
Contact* contact; Contact* contact;
PhoneBook phone_book; PhoneBook phone_book;
phone_book = PhoneBook();
while (true) while (true)
{ {
std::cout << "command: "; std::cout << "command: ";