Professional Documents
Culture Documents
Inheritance
Inheritance
Q1: Write a c++ program that contain base class of shape, this class should include:
Then create sub class and call it rectangle that should contain a function for area,
which area= width*height.
Another sub class call triangle that also have an area function, area = (width*height)/2.
Inside the main create new object from triangle, rectangle classes, then call set
functions and print the area of them.
**************************************************************************************************
Q2: Write c++ program that contain Animal class, the class should have:
Create sub class and name it Bird, this class inherits all the attribute from the base
class.
Inside the main create an object from Bird and call the constructors.
*************************************************************************************************
Perimeter = 2*(length+width).
*************************************************************************************************
Q4: write a C++ program to read and print students information using two classes and
simple inheritance. The program contains:
HW:
Imagine a publishing company that markets both book and audiocassette versions of its
works.
Create a class publication that stores the title (a string) and price (type float) of a publication
(in private scope).
From this class derive two classes:
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 book and tape classes by creating instances of them