C++ Tutorial: Some Lab assignments on Inheritance

Question: Create a class called Musicians to contain three methods string ( ), wind ( ) and perc ( ).
Each of these methods should initialize a string array to contain the following instruments
–  veena, guitar, sitar, sarod and mandolin under string ( )
–  flute, clarinet saxophone, nadhaswaram and piccolo under wind ( )
–  tabla, mridangam, bangos, drums and tambour under perc ( )
It should also display the contents of the arrays that are initialized. Create a derived class called TypeIns
to contain a method called get ( ) and show ( ). The get ( ) method must display a  means as follows
Type of instruments to be displayed
a.    String instruments
b.    ind instruments
c.    Percussion instruments
The show ( ) method should display the relevant detail according to our choice. The base class variables must be accessible
only to its derived classes.

Solution:

 

Question: Write three derived classes inheriting functionality of base class person (should have a member function that ask to enter name and age) and with added unique features of student, and employee, and functionality to assign, change and delete records of student and employee. And make one member function for printing address of the objects of classes (base and derived) using this pointer. Create two objects of base class and derived classes each and print the addresses of individual objects. Using calculator, calculate the address space occupied by each object and verify this with address spaces printed by the program.

Solution:

Question:  Write base class that ask the user to enter a complex number and derived class adds the complex number of its own with the base. Finally make third class that is friend of derived and calculate the difference of base complex number and its own complex number.

 

Solution:
SHARE C++ Tutorial: Some Lab assignments on Inheritance

You may also like...

1 Response

  1. Asma Khan says:

    In Question#2
    where is the code for …. " with added unique features of student, and employee, and functionality to assign, change and delete records of student and employee. " ???
    :/

Leave a Reply

Your email address will not be published. Required fields are marked *

Share