Uploaded by Ayman Abrar

abstract1

advertisement
Abstract
In this lab report we're exploring a key concept in C++ programming
called "inheritance." We'll create a table that shows how different
classes are related to each other. Then, we'll actually build these
classes in code and see how this sharing of characteristics helps us
organize our program better. Our main goal is to understand how
the base class and the derived classes work together. By doing this,
we can write code more efficiently and use a concept called
"polymorphism" to make our programs more flexible and powerful.
Introduction
Inheritance in C++ programming language that allows us to reuse the
code which is already written in base class.by using it we can make
changes to the base class and derived class.In this lab report we will
see how the inheritance chart is described with base class and
derived class. It allows classes to be related to each other so that a
base class can inherit from a derived class
Solution
1. First we make two class M and N.
2. This defines a class named N that inherits publicly from class M.
3. In class M it has a single public integer variable called ‘roll’. That
means “N” will have access to the ‘roll’.
4. Class N has a member function named ans() that prints the value
of roll to the console.
5. We can identify a total of nine unique combinations when
establishing the inheritance relationship between derived and base
classes.
page-01
Download