Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ (book.h) #include using namespace std; #ifndef BOOK_H #define BOOK_H class Book{ string title_; string author_; int issueYear_; int pages_; public: Book(string title_, string

in c++ (book.h)

#include using namespace std;

#ifndef BOOK_H #define BOOK_H class Book{

string title_; string author_; int issueYear_; int pages_;

public:

Book(string title_, string author_, int issueYear_, int pages_);

void setTitle(string title_); void setAuthor(string author_); void setIssueYear(int issueYear_); void setPages(int pages_);

string getTitle(); string getAuthor(); int getIssueYear(); int getPages();

void printDetails();

~Book();

};

#endif

(book_imp.cpp)

#include "Book.h" #include #include using namespace std;

Book::Book(string title_, string author_, int issueYear_, int pages_){ this->title_=title_; this->author_=author_; this->issueYear_=issueYear_; this->pages_=pages_; }

void Book::setTitle(string title_){ this->title_=title_; } void Book::setAuthor(string author_){ this->author_=author_; } void Book::setIssueYear(int issueYear_){ this->issueYear_=issueYear_; } void Book::setPages(int pages_){ this->pages_=pages_; }

string Book::getTitle(){ return this->title_; } string Book::getAuthor(){ return author_; } int Book::getIssueYear(){ return issueYear_; } int Book::getPages(){ return pages_; }

void Book::printDetails(){ cout<<"title: "<title_<author_<issueYear_<pages_<

Book::~Book(){ cout<<"Book destructor"<

NormalBook EBook (-) weight Type: int (-) sizeInByte Type: int (-) printType Type: string (-) fileType Type: string (+) Parameterized Constructor (+) Parameterized Constructor (+) Getters (+) Getters (+) Setters (+) Setters

QUESTION 1: The implementation of class Book is uploaded to the elearning. Copy Book.h and Book.cpp to your project.

QUESTION 2: 1. Implement class NormalBook, which inherits from class Book (use public inheritance). 2. Function printDetails of the base class should be overridden to print the additional information about the weight and print type.

QUESTION 3: Implement class EBook, which inherits from class Book (use protected inheritance). 1. Function getTitle in the base class should be overridden to return the title + (E-Book). 2. Function printDetails of the base class should be overridden to print the additional information about the size in bytes and file type.

QUESTION 4: Implement a driver program to test your code. 1. create an object of type NormalBook, assign the appropriate values for each data member, don't forget to assign values to parent class data members. 2. create an object of type EBook, assign the appropriate values for each data member, don't forget to assign values to parent class data members. 3. print the details of both objects. 4. change the title for both objects to be New title. Justify any error occurs. 5. print the title for both objects.

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_2

Step: 3

blur-text-image_3

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

Identify some training issues in the global context.

Answered: 1 week ago