SlideShare a Scribd company logo
1 of 4
Download to read offline
C++ 10.14 LAB: Book information (overriding member functions)
Given main() and a base Book class, define a derived class called Encyclopedia with member
functions to get and set private class data members of the following types:
- string to store the edition
- int to store the number of pages
Within the derived Encyclopedia class, define a PrintInfo() member function that overrides the
Book class' PrintInfo() function by printing the title, author, publisher, publication date, edition,
and number of pages.
Ex. If the input is:
the output is:
main.cpp
#include "Book.h"
#include "Encyclopedia.h"
#include
#include
using namespace std;
int main() {
Book myBook;
Encyclopedia myEncyclopedia;
string title, author, publisher, publicationDate;
string eTitle, eAuthor, ePublisher, ePublicationDate, edition;
int numPages;
getline(cin, title);
getline(cin, author);
getline(cin, publisher);
getline(cin, publicationDate);
getline(cin, eTitle);
getline(cin, eAuthor);
getline(cin, ePublisher);
getline(cin, ePublicationDate);
getline(cin, edition);
cin >> numPages;
myBook.SetTitle(title);
myBook.SetAuthor(author);
myBook.SetPublisher(publisher);
myBook.SetPublicationDate(publicationDate);
myBook.PrintInfo();
myEncyclopedia.SetTitle(eTitle);
myEncyclopedia.SetAuthor(eAuthor);
myEncyclopedia.SetPublisher(ePublisher);
myEncyclopedia.SetPublicationDate(ePublicationDate);
myEncyclopedia.SetEdition(edition);
myEncyclopedia.SetNumPages(numPages);
myEncyclopedia.PrintInfo();
return 0;
}
Book.h
#ifndef BOOKH
#define BOOKH
#include
using namespace std;
class Book {
public:
void SetTitle(string userTitle);
string GetTitle();
void SetAuthor(string userAuthor);
string GetAuthor();
void SetPublisher(string userPublisher);
string GetPublisher();
void SetPublicationDate(string userPublicationDate);
string GetPublicationDate();
void PrintInfo();
protected:
string title;
string author;
string publisher;
string publicationDate;
};
#endif
Book.cpp
#include "Book.h"
#include
void Book::SetTitle(string userTitle) {
title = userTitle;
}
string Book::GetTitle() {
return title;
}
void Book::SetAuthor(string userAuthor) {
author = userAuthor;
}
string Book::GetAuthor() {
return author;
}
void Book::SetPublisher(string userPublisher) {
publisher = userPublisher;
}
string Book::GetPublisher() {
return publisher;
}
void Book::SetPublicationDate(string userPublicationDate) {
publicationDate = userPublicationDate;
}
string Book::GetPublicationDate() {
return publicationDate;
}
void Book::PrintInfo() {
cout << "Book Information: " << endl;
cout << " Book Title: " << title << endl;
cout << " Author: " << author << endl;
cout << " Publisher: " << publisher << endl;
cout << " Publication Date: " << publicationDate << endl;
}
Encyclopedia.h
#ifndef ENCYCLOPEDIAH
#define ENCYCLOPEDIAH
#include "Book.h"
class Encyclopedia : public Book {
// TODO: Declare mutator functions -
// SetEdition(), SetNumPages()
// TODO: Declare accessor functions -
// GetEdition(), GetNumPages()
// TODO: Declare a PrintInfo() function that overrides
// the PrintInfo() in Book class
// TODO: Declare private data members
};
#endif
Encyclopedia.cpp
#include "Encyclopedia.h"
#include
// Define functions declared in Encyclopedia.h

More Related Content

Similar to C++ 10.14 LAB Book information (overriding member functions)Given.pdf

The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...PVS-Studio
 
Functional Java 8 in everyday life
Functional Java 8 in everyday lifeFunctional Java 8 in everyday life
Functional Java 8 in everyday lifeAndrea Iacono
 
Learn c sharp at amc square learning
Learn c sharp at amc square learningLearn c sharp at amc square learning
Learn c sharp at amc square learningASIT Education
 
PRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxPRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxabhishek364864
 
Kotlin Austin Droids April 14 2016
Kotlin Austin Droids April 14 2016Kotlin Austin Droids April 14 2016
Kotlin Austin Droids April 14 2016DesertJames
 
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docxC++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docxBrianGHiNewmanv
 
Intro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Intro To C++ - Class 07 - Headers, Interfaces, & PrototypesIntro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Intro To C++ - Class 07 - Headers, Interfaces, & PrototypesBlue Elephant Consulting
 
The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.8 book - Part 39 of 202The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.8 book - Part 39 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84Mahmoud Samir Fayed
 
descriptive programming
descriptive programmingdescriptive programming
descriptive programmingAnand Dhana
 
Hive Functions Cheat Sheet
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat SheetHortonworks
 

Similar to C++ 10.14 LAB Book information (overriding member functions)Given.pdf (20)

Spsl vi unit final
Spsl vi unit finalSpsl vi unit final
Spsl vi unit final
 
Spsl v unit - final
Spsl v unit - finalSpsl v unit - final
Spsl v unit - final
 
Rethinkdb
RethinkdbRethinkdb
Rethinkdb
 
CPP homework help
CPP homework helpCPP homework help
CPP homework help
 
Synapseindia dot net development
Synapseindia dot net developmentSynapseindia dot net development
Synapseindia dot net development
 
The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...
 
Functional Java 8 in everyday life
Functional Java 8 in everyday lifeFunctional Java 8 in everyday life
Functional Java 8 in everyday life
 
Learn c sharp at amc square learning
Learn c sharp at amc square learningLearn c sharp at amc square learning
Learn c sharp at amc square learning
 
PRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxPRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptx
 
Kotlin Austin Droids April 14 2016
Kotlin Austin Droids April 14 2016Kotlin Austin Droids April 14 2016
Kotlin Austin Droids April 14 2016
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
EEE 3rd year oops cat 3 ans
EEE 3rd year  oops cat 3  ansEEE 3rd year  oops cat 3  ans
EEE 3rd year oops cat 3 ans
 
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docxC++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx
 
Intro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Intro To C++ - Class 07 - Headers, Interfaces, & PrototypesIntro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Intro To C++ - Class 07 - Headers, Interfaces, & Prototypes
 
How c/c++ works
How c/c++ worksHow c/c++ works
How c/c++ works
 
The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.8 book - Part 39 of 202The Ring programming language version 1.8 book - Part 39 of 202
The Ring programming language version 1.8 book - Part 39 of 202
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84
 
Csharp_mahesh
Csharp_maheshCsharp_mahesh
Csharp_mahesh
 
descriptive programming
descriptive programmingdescriptive programming
descriptive programming
 
Hive Functions Cheat Sheet
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat Sheet
 

More from info189835

Can someone help with the implementation of these generic ArrayList .pdf
Can someone help with the implementation of these generic ArrayList .pdfCan someone help with the implementation of these generic ArrayList .pdf
Can someone help with the implementation of these generic ArrayList .pdfinfo189835
 
can someone help with the implementation of these generic DoublyLink.pdf
can someone help with the implementation of these generic DoublyLink.pdfcan someone help with the implementation of these generic DoublyLink.pdf
can someone help with the implementation of these generic DoublyLink.pdfinfo189835
 
can someone help with the implementation of these generic LinkedList.pdf
can someone help with the implementation of these generic LinkedList.pdfcan someone help with the implementation of these generic LinkedList.pdf
can someone help with the implementation of these generic LinkedList.pdfinfo189835
 
Can someone explain me the steps pleaseTake the provided files.pdf
Can someone explain me the steps pleaseTake the provided files.pdfCan someone explain me the steps pleaseTake the provided files.pdf
Can someone explain me the steps pleaseTake the provided files.pdfinfo189835
 
can someone briefly answer these questions please1) how socia.pdf
can someone briefly answer these questions please1) how socia.pdfcan someone briefly answer these questions please1) how socia.pdf
can someone briefly answer these questions please1) how socia.pdfinfo189835
 
Can anyone help me to understand why Consider a two way ANOVA model.pdf
Can anyone help me to understand why Consider a two way ANOVA model.pdfCan anyone help me to understand why Consider a two way ANOVA model.pdf
Can anyone help me to understand why Consider a two way ANOVA model.pdfinfo189835
 
can anyone help Prokaryotes are highly successful biological organi.pdf
can anyone help Prokaryotes are highly successful biological organi.pdfcan anyone help Prokaryotes are highly successful biological organi.pdf
can anyone help Prokaryotes are highly successful biological organi.pdfinfo189835
 
Cambios en los Activos y Pasivos Operativos Actuales�M�todo Indirect.pdf
Cambios en los Activos y Pasivos Operativos Actuales�M�todo Indirect.pdfCambios en los Activos y Pasivos Operativos Actuales�M�todo Indirect.pdf
Cambios en los Activos y Pasivos Operativos Actuales�M�todo Indirect.pdfinfo189835
 
California condors (Gymnogyps californianus) are listed on the IUCN .pdf
California condors (Gymnogyps californianus) are listed on the IUCN .pdfCalifornia condors (Gymnogyps californianus) are listed on the IUCN .pdf
California condors (Gymnogyps californianus) are listed on the IUCN .pdfinfo189835
 
California continues to face a water shortage. The quantity of water.pdf
California continues to face a water shortage. The quantity of water.pdfCalifornia continues to face a water shortage. The quantity of water.pdf
California continues to face a water shortage. The quantity of water.pdfinfo189835
 
Calculate the various ratios based on the following informationCa.pdf
Calculate the various ratios based on the following informationCa.pdfCalculate the various ratios based on the following informationCa.pdf
Calculate the various ratios based on the following informationCa.pdfinfo189835
 
calculate the return on assets calculate the return on equity ca.pdf
calculate the return on assets calculate the return on equity ca.pdfcalculate the return on assets calculate the return on equity ca.pdf
calculate the return on assets calculate the return on equity ca.pdfinfo189835
 
Calculate the frequency of alleles A and B for the two populations s.pdf
Calculate the frequency of alleles A and B for the two populations s.pdfCalculate the frequency of alleles A and B for the two populations s.pdf
Calculate the frequency of alleles A and B for the two populations s.pdfinfo189835
 
Calculate the Earnings Per Share (EPS) and Dividends Per Share (DPS).pdf
Calculate the Earnings Per Share (EPS) and Dividends Per Share (DPS).pdfCalculate the Earnings Per Share (EPS) and Dividends Per Share (DPS).pdf
Calculate the Earnings Per Share (EPS) and Dividends Per Share (DPS).pdfinfo189835
 
Calculate the of total (portfolio weight) for eachStock A pr.pdf
Calculate the  of total (portfolio weight) for eachStock A pr.pdfCalculate the  of total (portfolio weight) for eachStock A pr.pdf
Calculate the of total (portfolio weight) for eachStock A pr.pdfinfo189835
 
Calculate R2. (Round your answer to 4 decimal places.)Moviegoer Sp.pdf
Calculate R2. (Round your answer to 4 decimal places.)Moviegoer Sp.pdfCalculate R2. (Round your answer to 4 decimal places.)Moviegoer Sp.pdf
Calculate R2. (Round your answer to 4 decimal places.)Moviegoer Sp.pdfinfo189835
 
Cada vez es m�s dif�cil mantenerse al d�a con los problemas tecnol�g.pdf
Cada vez es m�s dif�cil mantenerse al d�a con los problemas tecnol�g.pdfCada vez es m�s dif�cil mantenerse al d�a con los problemas tecnol�g.pdf
Cada vez es m�s dif�cil mantenerse al d�a con los problemas tecnol�g.pdfinfo189835
 
Cada una de las siguientes cuentas se reporta como pasivo a largo pl.pdf
Cada una de las siguientes cuentas se reporta como pasivo a largo pl.pdfCada una de las siguientes cuentas se reporta como pasivo a largo pl.pdf
Cada una de las siguientes cuentas se reporta como pasivo a largo pl.pdfinfo189835
 
C coding into MIPS coding (Make sure this code works on Qtmips) Ho.pdf
C coding into MIPS coding (Make sure this code works on Qtmips) Ho.pdfC coding into MIPS coding (Make sure this code works on Qtmips) Ho.pdf
C coding into MIPS coding (Make sure this code works on Qtmips) Ho.pdfinfo189835
 
C++ help finish my code Phase 1 - input phase. Main reads the fi.pdf
C++ help finish my code Phase 1 - input phase. Main reads the fi.pdfC++ help finish my code Phase 1 - input phase. Main reads the fi.pdf
C++ help finish my code Phase 1 - input phase. Main reads the fi.pdfinfo189835
 

More from info189835 (20)

Can someone help with the implementation of these generic ArrayList .pdf
Can someone help with the implementation of these generic ArrayList .pdfCan someone help with the implementation of these generic ArrayList .pdf
Can someone help with the implementation of these generic ArrayList .pdf
 
can someone help with the implementation of these generic DoublyLink.pdf
can someone help with the implementation of these generic DoublyLink.pdfcan someone help with the implementation of these generic DoublyLink.pdf
can someone help with the implementation of these generic DoublyLink.pdf
 
can someone help with the implementation of these generic LinkedList.pdf
can someone help with the implementation of these generic LinkedList.pdfcan someone help with the implementation of these generic LinkedList.pdf
can someone help with the implementation of these generic LinkedList.pdf
 
Can someone explain me the steps pleaseTake the provided files.pdf
Can someone explain me the steps pleaseTake the provided files.pdfCan someone explain me the steps pleaseTake the provided files.pdf
Can someone explain me the steps pleaseTake the provided files.pdf
 
can someone briefly answer these questions please1) how socia.pdf
can someone briefly answer these questions please1) how socia.pdfcan someone briefly answer these questions please1) how socia.pdf
can someone briefly answer these questions please1) how socia.pdf
 
Can anyone help me to understand why Consider a two way ANOVA model.pdf
Can anyone help me to understand why Consider a two way ANOVA model.pdfCan anyone help me to understand why Consider a two way ANOVA model.pdf
Can anyone help me to understand why Consider a two way ANOVA model.pdf
 
can anyone help Prokaryotes are highly successful biological organi.pdf
can anyone help Prokaryotes are highly successful biological organi.pdfcan anyone help Prokaryotes are highly successful biological organi.pdf
can anyone help Prokaryotes are highly successful biological organi.pdf
 
Cambios en los Activos y Pasivos Operativos Actuales�M�todo Indirect.pdf
Cambios en los Activos y Pasivos Operativos Actuales�M�todo Indirect.pdfCambios en los Activos y Pasivos Operativos Actuales�M�todo Indirect.pdf
Cambios en los Activos y Pasivos Operativos Actuales�M�todo Indirect.pdf
 
California condors (Gymnogyps californianus) are listed on the IUCN .pdf
California condors (Gymnogyps californianus) are listed on the IUCN .pdfCalifornia condors (Gymnogyps californianus) are listed on the IUCN .pdf
California condors (Gymnogyps californianus) are listed on the IUCN .pdf
 
California continues to face a water shortage. The quantity of water.pdf
California continues to face a water shortage. The quantity of water.pdfCalifornia continues to face a water shortage. The quantity of water.pdf
California continues to face a water shortage. The quantity of water.pdf
 
Calculate the various ratios based on the following informationCa.pdf
Calculate the various ratios based on the following informationCa.pdfCalculate the various ratios based on the following informationCa.pdf
Calculate the various ratios based on the following informationCa.pdf
 
calculate the return on assets calculate the return on equity ca.pdf
calculate the return on assets calculate the return on equity ca.pdfcalculate the return on assets calculate the return on equity ca.pdf
calculate the return on assets calculate the return on equity ca.pdf
 
Calculate the frequency of alleles A and B for the two populations s.pdf
Calculate the frequency of alleles A and B for the two populations s.pdfCalculate the frequency of alleles A and B for the two populations s.pdf
Calculate the frequency of alleles A and B for the two populations s.pdf
 
Calculate the Earnings Per Share (EPS) and Dividends Per Share (DPS).pdf
Calculate the Earnings Per Share (EPS) and Dividends Per Share (DPS).pdfCalculate the Earnings Per Share (EPS) and Dividends Per Share (DPS).pdf
Calculate the Earnings Per Share (EPS) and Dividends Per Share (DPS).pdf
 
Calculate the of total (portfolio weight) for eachStock A pr.pdf
Calculate the  of total (portfolio weight) for eachStock A pr.pdfCalculate the  of total (portfolio weight) for eachStock A pr.pdf
Calculate the of total (portfolio weight) for eachStock A pr.pdf
 
Calculate R2. (Round your answer to 4 decimal places.)Moviegoer Sp.pdf
Calculate R2. (Round your answer to 4 decimal places.)Moviegoer Sp.pdfCalculate R2. (Round your answer to 4 decimal places.)Moviegoer Sp.pdf
Calculate R2. (Round your answer to 4 decimal places.)Moviegoer Sp.pdf
 
Cada vez es m�s dif�cil mantenerse al d�a con los problemas tecnol�g.pdf
Cada vez es m�s dif�cil mantenerse al d�a con los problemas tecnol�g.pdfCada vez es m�s dif�cil mantenerse al d�a con los problemas tecnol�g.pdf
Cada vez es m�s dif�cil mantenerse al d�a con los problemas tecnol�g.pdf
 
Cada una de las siguientes cuentas se reporta como pasivo a largo pl.pdf
Cada una de las siguientes cuentas se reporta como pasivo a largo pl.pdfCada una de las siguientes cuentas se reporta como pasivo a largo pl.pdf
Cada una de las siguientes cuentas se reporta como pasivo a largo pl.pdf
 
C coding into MIPS coding (Make sure this code works on Qtmips) Ho.pdf
C coding into MIPS coding (Make sure this code works on Qtmips) Ho.pdfC coding into MIPS coding (Make sure this code works on Qtmips) Ho.pdf
C coding into MIPS coding (Make sure this code works on Qtmips) Ho.pdf
 
C++ help finish my code Phase 1 - input phase. Main reads the fi.pdf
C++ help finish my code Phase 1 - input phase. Main reads the fi.pdfC++ help finish my code Phase 1 - input phase. Main reads the fi.pdf
C++ help finish my code Phase 1 - input phase. Main reads the fi.pdf
 

Recently uploaded

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Recently uploaded (20)

OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

C++ 10.14 LAB Book information (overriding member functions)Given.pdf

  • 1. C++ 10.14 LAB: Book information (overriding member functions) Given main() and a base Book class, define a derived class called Encyclopedia with member functions to get and set private class data members of the following types: - string to store the edition - int to store the number of pages Within the derived Encyclopedia class, define a PrintInfo() member function that overrides the Book class' PrintInfo() function by printing the title, author, publisher, publication date, edition, and number of pages. Ex. If the input is: the output is: main.cpp #include "Book.h" #include "Encyclopedia.h" #include #include using namespace std; int main() { Book myBook; Encyclopedia myEncyclopedia; string title, author, publisher, publicationDate; string eTitle, eAuthor, ePublisher, ePublicationDate, edition; int numPages; getline(cin, title); getline(cin, author); getline(cin, publisher); getline(cin, publicationDate); getline(cin, eTitle); getline(cin, eAuthor); getline(cin, ePublisher); getline(cin, ePublicationDate); getline(cin, edition); cin >> numPages; myBook.SetTitle(title); myBook.SetAuthor(author); myBook.SetPublisher(publisher);
  • 2. myBook.SetPublicationDate(publicationDate); myBook.PrintInfo(); myEncyclopedia.SetTitle(eTitle); myEncyclopedia.SetAuthor(eAuthor); myEncyclopedia.SetPublisher(ePublisher); myEncyclopedia.SetPublicationDate(ePublicationDate); myEncyclopedia.SetEdition(edition); myEncyclopedia.SetNumPages(numPages); myEncyclopedia.PrintInfo(); return 0; } Book.h #ifndef BOOKH #define BOOKH #include using namespace std; class Book { public: void SetTitle(string userTitle); string GetTitle(); void SetAuthor(string userAuthor); string GetAuthor(); void SetPublisher(string userPublisher); string GetPublisher(); void SetPublicationDate(string userPublicationDate); string GetPublicationDate(); void PrintInfo(); protected: string title; string author; string publisher; string publicationDate; }; #endif Book.cpp #include "Book.h"
  • 3. #include void Book::SetTitle(string userTitle) { title = userTitle; } string Book::GetTitle() { return title; } void Book::SetAuthor(string userAuthor) { author = userAuthor; } string Book::GetAuthor() { return author; } void Book::SetPublisher(string userPublisher) { publisher = userPublisher; } string Book::GetPublisher() { return publisher; } void Book::SetPublicationDate(string userPublicationDate) { publicationDate = userPublicationDate; } string Book::GetPublicationDate() { return publicationDate; } void Book::PrintInfo() { cout << "Book Information: " << endl; cout << " Book Title: " << title << endl; cout << " Author: " << author << endl; cout << " Publisher: " << publisher << endl; cout << " Publication Date: " << publicationDate << endl; } Encyclopedia.h #ifndef ENCYCLOPEDIAH #define ENCYCLOPEDIAH #include "Book.h"
  • 4. class Encyclopedia : public Book { // TODO: Declare mutator functions - // SetEdition(), SetNumPages() // TODO: Declare accessor functions - // GetEdition(), GetNumPages() // TODO: Declare a PrintInfo() function that overrides // the PrintInfo() in Book class // TODO: Declare private data members }; #endif Encyclopedia.cpp #include "Encyclopedia.h" #include // Define functions declared in Encyclopedia.h