Question: C++ Solve the code please. #pragma once /* * CECS 2223, Computer Programming II Laboratory * Winter 2022, Sec. 05 * Date: December 19, 2022

C++ Solve the code please.

#pragma once /* * CECS 2223, Computer Programming II Laboratory * Winter 2022, Sec. 05 * Date: December 19, 2022 * Topic: Lab 4 - Dynamic Memory * File name: Book.h * YOUR NAME, YOUR ID NUMBER * This file declares a class named Book */ // Which header files should be included? class Book { private: static int booksCreated; string title; int pages; int bookNumber; public: Book(); Book(Book&); ~Book(); void setTitle(string); void setPages(int); int getBooksCreated() const; string getTitle() const; int getPages() const; int getBookNumber() const; void printBook() const; }; /* * CECS 2223, Computer Programming II Laboratory * Winter 2022, Sec. 05 * Date: December 19, 2022 * Topic: Lab 4 - Dynamic Memory * File name: Book.cpp * YOUR NAME, YOUR ID NUMBER * This file defines a class named Book */ // Which header files should be included? // The class variable is initialized to 0 // The default constructor initializes the title to the // empty string and pages to 0. bookNumber is initialized // to one more than the current value of booksCreated, // and booksCreated is incremented. // The copy constructor initializes bookNumber to one more // than the current value of booksCreated, and booksCreated // is incremented. It initializes the title and pages to the // same value as that of the title and pages of the parameter. // The destructor prints the phrase "Book number [number] has // been removed from the collection" // define the setters and getters // The printBook method uses printf to print the book's state // in a table ready format. It prints the book number aligned // to the left in a 3-space column, the number of pages also // aligned to the left in an 8-space column, and finally the // book's title (no column size). /* * CECS 2223, Computer Programming II Laboratory * Winter 2022, Sec. 05 * Date: December 19, 2022 * Topic: Lab 4 - Dynamic Memory * File name: lab04.cpp * YOUR NAME, YOUR ID NUMBER * This file implements a class named Book */ // Which header files should be included? int main() { // declare a pointer to a Book object named myCollection // and initialize it to the null pointer // declare an integer variable named books and initialize it to 0 // prompt the user for the amount of books using the phrase // "Enter the amount of books in your collection: ", and store // the value in the previously declared integer variable // The value used must be greater then 3 // Create a Book array using the number of books as the size // Implement a for iteration control structure to prompt the user // for the title and number of pages of each book in the collection // Create a Book object named copia using the copy constructor and // the reference of the second book in the array. // Change the title of copia to add Volume II at the end // print the following header using the same column sizes as in printBook // The data to be printed is the # symbol, PAGES, and TITLE // Using a for iteration control structure call the print method for each book // Release the memory allocated to the Book array // print a statement with your personal information using the phrase // "--- Program developed by [YOUR NAME], ID# [YOUR ID NUMBER] ---" // where the square brackets and the text within is substituted with your personal // information. Make sure to add a blank line before and after the phrase is printed. system(" pause"); // For Visual Studio only! return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!