Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
18 views

Publication That Stores The Title (A Char Array) and Price

This document describes an object-oriented programming lab on levels of inheritance. It involves creating classes for publications like books and audiocassettes with attributes like title, price, and additional attributes for books (page count) and tapes (playing time). Then it describes deriving a new publication2 class to add a date attribute and changing the book and tape classes to inherit from publication2 instead of publication.

Uploaded by

Lovely Jutt
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Publication That Stores The Title (A Char Array) and Price

This document describes an object-oriented programming lab on levels of inheritance. It involves creating classes for publications like books and audiocassettes with attributes like title, price, and additional attributes for books (page count) and tapes (playing time). Then it describes deriving a new publication2 class to add a date attribute and changing the book and tape classes to inherit from publication2 instead of publication.

Uploaded by

Lovely Jutt
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Object Oriented Programming

Lab 12
Topic Covered: Levels of Inheritance

1. Imagine a publishing company that markets both book and


audiocassette versions of its works. Create a class
publication that stores the title (a char array) and price
(type float) of a publication. From this class derive two
classes: book, which adds a page count (type int), and
tape, which adds a playing time in minutes (type float).
Each of these three classes should have a getdata()
function to get its data from the user at the keyboard,
and a putdata() function to display its data.
Write a main () program to test the classes by creating
instances of book and tape class, asking the user to fill in
data with getdata(), and then displaying the data with
putdata().
2. Suppose you want to add the date (three int, for month,
day, and year) of publication for both books and tapes.
From the publication class, derive a new class called
publication2 that includes these member data attributes
along with the getdata() and putdata() methods. Make all
the necessary changes in member functions so the user can
input and output dates along with the other data. Then
change book and tape so that they are derived from
publication2 instead of publication class.
Write a main() program to test the classes by creating
instances of book and tape class, asking the user to fill in
data with getdata(), and then displaying the data with
putdata().

You might also like