Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: Create a struct named AddressBook that stores multiple Entry structs (that you created in the previous exercise). Your code must be saved in a

Question: Create a struct named AddressBook that stores multiple Entry structs (that you created in the previous exercise). Your code must be saved in a file named AddressBook.h and should reuse your code from Entry.h.

Member functions for AddressBook should be able to add an entry and print all the entries in the address book. Your code will be tested with the file addressBook.cpp, which reads in several entries from standard input, stores them in an AddressBook instance and prints them all out.

addressBook.cpp:

#include  #include "AddressBook.h" int main(int argc, const char * argv[]) { int n; cin >> n; string name, lastname, email; cin >> name; cin >> lastname; cin >> email; AddressBook * myAddressBook = new AddressBook(name, lastname, email); AddressBook * current; for (int i = 1; i < n; i++) { cin >> name; cin >> lastname; cin >> email; current = new AddressBook(name, lastname, email); myAddressBook->add(current); } myAddressBook->print(); return 0; } 

Sample Input:

5 Jack Daniel jack@yahoo.com Jose Cuervo jose@yahoo.com Johnnie Walker johnnie@yahoo.com Pierre Smirnoff pierre@yahoo.com Richard Hennessy richard@yahoo.com

Sample Output:

First Name: Jack Last Name: Daniel Email: jack@yahoo.com

First Name: Jose Last Name: Cuervo Email: jose@yahoo.com

First Name: Johnnie Last Name: Walker Email: johnnie@yahoo.com

First Name: Pierre Last Name: Smirnoff Email: pierre@yahoo.com

First Name: Richard Last Name: Hennessy Email: richard@yahoo.com

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions