Concepts of OOPs
Concept of Oop's( object oriented programming)
Object oriented programming:-
>>As the name suggested object oriented programing used objects in programming.
>> object-oriented programming aims to implement the entities in programming.
>> The basic aim of oops is to bind together and function the operation on them. So, that no other part of the code can access this data except that function.
Basic concept (or) characteristics (or) features of oops.
The following are characteristics of oops
1.Class
2.Object
3.Encapsulation
4.Data abstraction
5.Inheritance
6.Polymorphism
π₯π₯】1.Class【π₯π₯
The concept of class is always used to developing the user defined data.
i] Class is a basic building block of object oriented programming.
ii] class hold its own data members and member functions which can accessd and used by creating an instant of the class.
iii]Class is like a blueprint for an object.
iv] whenever we define a class there is no memory space for data members and associated methods of class.
Ex:- consider the CAR
>> there maybe many cars with different names and brands but all of them will share some common properties of will have four wheel, speed limit, mileage Range . So, here CAR is a class speed limit ,mileage range are properties and applications break increase speed etc.., are functions.
⚜️⚜️】2.Object【⚜️⚜️
An object is an instance of class . Instance is nothing but allocating sufficient memory for members of class.
i]whenever we define a class there is no memory space for data members and associated methods of class. When we create an object of a class memory space will be created for member of class.
ii] Real world entities are known as objects.
iii] Value from a class are known as objects.
Ex:- CAR-Class(absent-exist in real world).
SWIFT CAR-Object(exist in real world).
✡️☯️】3.Data Obstruction【☯️✡️
Data abstraction represented to provide only essential information to the outside world and finding their background details.
Ex:-if we consider a TV, we can turn off and on change ,the channels ,adjust the volume and add external components such as speaker and DVD player . But ,we don't know how they internally work.
➡️ In similar way in C + +, class provides great level of data abstraction they provide sufficient public methods to outside the world to play with the functions of the objects and to manipulate object data that is state without actually knowing how class has been implemented internally.
Ex:-Our program can make a call to the short() function. Without knowing what algorithms the functions available using for short() the given value.
✴️✳️】Encapsulation 【✳️✴️
Encapsulation is a process of combining data members and member functions into a single unit called class.
π²️This is to prevent the access to the data directly the access to the data is provided through the function of class this is one of the popular future of the object-oriented programming.
π’π₯】5.Inheritance【π₯π’
Inheritance is the capability of a class to acquire the properties and characters from another class.
♠️The class whose properties are inherited by another class is called parent (or) base (or) super class.
♠️ The class which inherited properties of another class is called child (or) derived (or) sub-class.
♠️When we inherited and exiting class, all its methods and Fields become available in the new class, hence the code is reduced.
π⚜️】6.Polymorphism【⚜️π
The word polymorphism means many forms.
Ex:-A person possesses different behaviour in a different situation ,at a some time is a father ,a husband ,an employee this is called the polymorphism.
In C++ polymorphism is mainly divided into types.
1.Compiler time polymorphism
2.Run time polymorphism.
π²π²i.Compiler time polymorphism
This type of polymorphism is achieved by function overloading (or) operator overloading.
♠️ function overloading means function with a same name . But, with a different number of augment (or) a type of augment (or) order of augment.
π₯π₯ii]Run time Polymorphyshism
This type of polymorphism is achieved by function overriding.
♠️ function overloading on other hand occurs where we derived class has a define for one of the Member function of the base class. The base function is said to be overriding
Comments