Basic Overview Of OOP Principles
1.) Data Abstraction:-
-> Data Abstraction is one of the most imporatnt and essential feature of Object oriented programming.
Abstraction means showing essential features by hiding background details.
-> Consider a real life example of Data Abstraction-
A man driving a car. The man only knows that pressing the accelerators will increase the speed of car or applying brakes will stop the car but he does not know about how on pressing accelerator the speed is actually increasing, he does not know about the inner mechanism of the car or the implementation of accelerator, brakes etc in the car.
-> We can implement Abstraction in C++ using classes. Class helps us to group data members and member functions using available access specifiers. A Class can decide which data member will be visible to outside world and which is not.
2.) Data Encapsulation:-
-> In Object Oriented Programming, Encapsulation is defined as binding together the data and the functions that manipulates them. Encapsulation means Combining data and coding into a single unit is known as Data Encapsulation.
-> Role of access specifiers in encapsulation
As we have seen in above example, access specifiers plays an important role in implementing encapsulation in C++. The process of implementing encapsulation can be sub-divided into two steps:
1. The data members should be labeled as private using the private access specifiers.
2. The member function which manipulates the data members should be labeled as public using the public access specifier.
3.) Inheritance:-
The capability of a class to derive properties and characteristics from another class is called Inheritance. Inheritance is one of the most important feature of Object Oriented Programming.
Sub Class: The class that inherits properties from another class is called Sub class or Derived Class.
Super Class:The class whose properties are inherited by sub class is called Base Class or Super class.
* Ability of Reusing the existing code without defining it again and again called, inheritance.
4.) Polymorphism:-
-> It is a Greek word. poly means many and morphism means forms.
-> polymorphism as the ability of a message to be displayed in more than one form.
Real life example of polymorphism, A person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee. So the same person posses different behavior in different situations. This is called polymorphism.
-> Operator overloading & function overloading are examples of polymorphism.
1.) Function Overloading:
The function name has more than one definition in a class according to arguments passed to a function.
2.) Operator Overloading:
Uses predefined operators as function name and allow giving it new definition.
5.) Objects:-
-> Class type variable is known as object.
-> An object is an instance of a class.
-> Objects are basic runtime entities in an object oriented system.
-> In Structured programming problem is divided into function unlike this, in OOPs the problem is divided into objects.
6.) Class:-
-> Language supports different data type like int, float, char, long, structure etc. Similar to that C++ supports class data type.
-> A class is a user defined data type which has data members and member functions. They can be accessed through class variables (objects).
-> A class is like a Blue print for an object.
-> By default, All members in the class are Private.
For Ex:
Fruit is a class.
Then mango, orange will be objects of class.
1.) Data Abstraction:-
-> Data Abstraction is one of the most imporatnt and essential feature of Object oriented programming.
Abstraction means showing essential features by hiding background details.
-> Consider a real life example of Data Abstraction-
A man driving a car. The man only knows that pressing the accelerators will increase the speed of car or applying brakes will stop the car but he does not know about how on pressing accelerator the speed is actually increasing, he does not know about the inner mechanism of the car or the implementation of accelerator, brakes etc in the car.
-> We can implement Abstraction in C++ using classes. Class helps us to group data members and member functions using available access specifiers. A Class can decide which data member will be visible to outside world and which is not.
2.) Data Encapsulation:-
-> In Object Oriented Programming, Encapsulation is defined as binding together the data and the functions that manipulates them. Encapsulation means Combining data and coding into a single unit is known as Data Encapsulation.
-> Role of access specifiers in encapsulation
As we have seen in above example, access specifiers plays an important role in implementing encapsulation in C++. The process of implementing encapsulation can be sub-divided into two steps:
1. The data members should be labeled as private using the private access specifiers.
2. The member function which manipulates the data members should be labeled as public using the public access specifier.
3.) Inheritance:-
The capability of a class to derive properties and characteristics from another class is called Inheritance. Inheritance is one of the most important feature of Object Oriented Programming.
Sub Class: The class that inherits properties from another class is called Sub class or Derived Class.
Super Class:The class whose properties are inherited by sub class is called Base Class or Super class.
* Ability of Reusing the existing code without defining it again and again called, inheritance.
4.) Polymorphism:-
-> It is a Greek word. poly means many and morphism means forms.
-> polymorphism as the ability of a message to be displayed in more than one form.
Real life example of polymorphism, A person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee. So the same person posses different behavior in different situations. This is called polymorphism.
-> Operator overloading & function overloading are examples of polymorphism.
1.) Function Overloading:
The function name has more than one definition in a class according to arguments passed to a function.
2.) Operator Overloading:
Uses predefined operators as function name and allow giving it new definition.
5.) Objects:-
-> Class type variable is known as object.
-> An object is an instance of a class.
-> Objects are basic runtime entities in an object oriented system.
-> In Structured programming problem is divided into function unlike this, in OOPs the problem is divided into objects.
6.) Class:-
-> Language supports different data type like int, float, char, long, structure etc. Similar to that C++ supports class data type.
-> A class is a user defined data type which has data members and member functions. They can be accessed through class variables (objects).
-> A class is like a Blue print for an object.
-> By default, All members in the class are Private.
For Ex:
Fruit is a class.
Then mango, orange will be objects of class.