0% found this document useful (0 votes)
4 views1 page

Sample Programs-Inheritance & Functions

The document outlines several sample C++ programming exercises focusing on different types of inheritance including single, multilevel, multiple, and hierarchical inheritance. It also includes tasks for using inline functions, calculating simple interest with default arguments, and implementing friend functions for class access. Each exercise emphasizes practical application of object-oriented programming concepts in C++.

Uploaded by

cojogan898
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Sample Programs-Inheritance & Functions

The document outlines several sample C++ programming exercises focusing on different types of inheritance including single, multilevel, multiple, and hierarchical inheritance. It also includes tasks for using inline functions, calculating simple interest with default arguments, and implementing friend functions for class access. Each exercise emphasizes practical application of object-oriented programming concepts in C++.

Uploaded by

cojogan898
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Sample Programs

1. Write a C++ program using single inheritance where a base class Person has name and age,
and a derived class Student has a roll number. Display all information.
2. Create a multilevel inheritance program where a Vehicle class is inherited by Car, and Car is
inherited by ElectricCar.
3. Use multiple inheritance where a Writer class and Singer class are inherited by a Performer
class. Show how Performer can access both base class members.
4. Hierarchical Inheritance: Create a base class Shape with a function to input and display
dimensions. Inherit Rectangle and Triangle classes and calculate area.
5. Write a program using an inline function to calculate the square of a number.
6. Write a program to calculate simple interest. Use a function with default argument for the rate
of interest.
7. Create a class Circle with a private radius. Write a friend function (outside the class) to
calculate the area of the circle.

You might also like