Write a class named Book that has the following data members: - title :: A string that holds the book's title. - name :: A string that holds the name of the book's author pages :: An int variable that holds the number of pages in the book.
Write a class named Book that has the following data members: - title :: A string that holds the book's title. - name :: A string that holds the name of the book's author pages :: An int variable that holds the number of pages in the book.
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 11PE
Related questions
Concept explainers
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Question
Write a code in C++ for the following question,
![Write a class named Book that has the following data members:
- title :: A string that holds the book's title.
- name :: A string that holds the name of the book's author
- pages :: An int variable that holds the number of pages in the book.
Next, you should create a Library class that has Book object as a private attribute. It should also have
attributes for the 'subject' and 'shelf number'. The Library class should have a member function,
printBookDetails() that prints the details of the book with its location information in the Library.
Write a driver program to test the class Library.
The program should have the following additional requirements:
▪ The Book class should have a constructor to initialize the object and appropriate getter
functions to return the data of a Book object.
▪ The Library class should have a constructor to initialize its object with appropriate values of
its three data members.
▪ Use member-list initializers for both the constructors of the classes.
▪ Minimum three files (main.cpp, Book.h, Library.h). Submit your code as:
LastName_FirstName_Q1.zip (containing all files).
Example output:
Title: C++ How to Program
Author: Deitel and Deitel
Pages: 1104
Subject: Computer Programming
Shelf Number: 5](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F72418d22-4619-4199-9799-b47710ae5c0e%2F62689184-54e5-4e35-ad1b-8f23a3a6118b%2Fwmh2av_processed.png&w=3840&q=75)
Transcribed Image Text:Write a class named Book that has the following data members:
- title :: A string that holds the book's title.
- name :: A string that holds the name of the book's author
- pages :: An int variable that holds the number of pages in the book.
Next, you should create a Library class that has Book object as a private attribute. It should also have
attributes for the 'subject' and 'shelf number'. The Library class should have a member function,
printBookDetails() that prints the details of the book with its location information in the Library.
Write a driver program to test the class Library.
The program should have the following additional requirements:
▪ The Book class should have a constructor to initialize the object and appropriate getter
functions to return the data of a Book object.
▪ The Library class should have a constructor to initialize its object with appropriate values of
its three data members.
▪ Use member-list initializers for both the constructors of the classes.
▪ Minimum three files (main.cpp, Book.h, Library.h). Submit your code as:
LastName_FirstName_Q1.zip (containing all files).
Example output:
Title: C++ How to Program
Author: Deitel and Deitel
Pages: 1104
Subject: Computer Programming
Shelf Number: 5
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 7 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,