Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hi,I have a small part of a code where I have a list of pointers to book and a list of pointer to borrowers. The

hi,I have a small part of a code where I have a list of pointers to book and a list of pointer to borrowers. The class person is an abstract class therefore we cant create object of this class only an array of pointers. The part where the arrays are initialized doesnt work (books=new Book[1000] and borrowers=new Person[200]) I tried to write *books=new Book[1000] it works but not for the borrowers because I cant create objects of that class. Also, how can I use those arrays in the next functions? No need to use the exact same program if you have a similar one I just need to understand how it works. image text in transcribed
image text in transcribed
image text in transcribed
nibrary.h-definition of the class Library #include #include-person #include-boost: class Library private string name name of the library string address address of the library Book" books int numBooks l ist of pointers to books Il keeps track of number of books Person borrowers; Il list of pointers to persons int numBorrowers I keeps track of number of borrowers public: /I default constructor ll regular constructor Library0 Library(string, string) Library(const Library&) li copy constructor virtual Library0: l destructor Functions that deal with name and address / Subsystem that deals with persons void addBorrower(const Person*) ii adds a borrower void removeBorrowerint id): vold listAllBorrowers0 const bool searcheorroweron) const; # searches for a borrower Il removes a borrower Il lists all borrowers # Subsystem that deals with books void borroweook(const Book.); # adds a book void returnBook(Book b), void listAllBooks0 const bool searchBook int) const ll searches if a person borrowed a book using id bool searchBook(string) const ii searches if a person borrowed a book using title l removes a book l lists all books borrowed by a person Detaut constructor Library: Library name " books new Book(1000 Il What happens here? borrowers new Person/200;/ What happens here? Il Adds a borrower void Library: addBorrowericonst Person* p) t if (numBorrowers getDo)Il exists should be added to the class as a private functi numBorrowers++ else ( cout getName0 getName0

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

Optimization And Data Science Trends And Applications 5th Airoyoung Workshop And Airo Phd School 2021 Joint Event

Authors: Adriano Masone ,Veronica Dal Sasso ,Valentina Morandi

1st Edition

3030862887, 978-3030862886

More Books

Students also viewed these Databases questions

Question

recognise typical interviewer errors and explain how to avoid them

Answered: 1 week ago

Question

identify and evaluate a range of recruitment and selection methods

Answered: 1 week ago

Question

understand the role of competencies and a competency framework

Answered: 1 week ago