Introduction To C++ OOPs Concept
Introduction To C++ OOPs Concept
1. A class is user defined data type which holds both data and function to operate on
them the data of the class is called Data member. And the function of the class
are called Member function.
2. These member can be private and public. By default all members of a class are
private.
3. We can specify the member as public. The private member of the class cannot be
accessed outside the class.
4. Class is like a blue print for an object.
OBJECT
Introduction to inheritance: -
1. The capability of a class to derive the properties and charters tics from another class is
inheritance.
2. Inheritance is one of the most important feature of OOPs that allow the child class to acquire
the properties (data members) and functionalities (member function) of parent class.
3. Child class: - a class that inherits another class is know as child class, sub class & derived
class.
4. Parent class: - the class that is being inherited by other class is known as parent class, super
class & base class.
TYPES OF
INHERITANCE
Single inheritance
Multilevel inheritance
Hierarchal inheritance
Multiple inheritance
Hybrid inheritance
SINGLE INHERITANCE
1. In this type of inheritance there is
only one parent class and one child
class.
2. The child class inherits the
properties and characteristics of the
parent class.
MULTILEVEL
INHERITANCE
In this type of inheritance class A is
inherited by class B and class C inherits
the class B that is why this is called
multilevel inheritance.
HIERARCHICAL INHERITANCE
1. In this type of inheritance there is only one parent class and two or three child
class.
2. These classes inherits properties of the parent class. So this inheritance is also
called hierarchical inheritance.
MULTIPLE INHERITANCE
1. In this type of inheritance there is only one child class and two
or three parent class.
2. That single child class inherits the properties of three parent
class . i.e. this is also known as multiple inheritance.
HYBRID INHERITANCE
This type of inheritance is a combination of two types
of inheritance, that is why this is also called hybrid
inheritance. But there is an anomaly, which is that class
B and class C both inherits the class A which is parent
class, so both class have same copy of their parent class
which is class A. So that system gets confused by
getting two copies of class A by class B and class C and
both of these classes are inherited by class D there is
way to remove this anomaly, which is- define classes as
virtual class so that both class, B and C have virtual
copies of class A so system doesn’t get confused for
class A. This inheritance is also known for making
diamond structure.
POLYMORPHISM