Object-Oriented Programming (OOPs) in C language
Object-Oriented Programming (OOP) in C language |
The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except this function.
Class: It is a user-defined data type, which holds its own data members, which can be accessed and used by creating an instance of that class.
Object: When a class is defined on memory is allocated but when it is instantiated (i.e, object is created ) memory is allocated.
Encapsulation: In OOP, Encapsulation is defined as binding together the data and the functions that manipulate them.
Abstraction: Abstraction means displaying only essential information and hiding the details
- Abstraction using classes
- Abstraction using header files (math.n--------> pow())
Polymorphism: in simple words, we can define polymorphism as the ability of messages to be displayed in more than one form.
- Operator overloading
- function overloading
Inheritance: The capability of a class to derive properties and characteristics from another class is called inheritance.
- Subclass
- Superclass
- Reusability
Dynamic Binding: In dynamic binding, the code to be executed in response to the function call is decided at run time.
Constructors: A constructor is a member function of a class which initializes object of a class. In c++ constructor is automatically called when the object creates.
It has the same name as the class itself.
- Default constructor (no parameter passed )
- parametrized constructor
- copy constructor
Destructor in C++: Derived class destructor will be invoked first, then the base class destructor will be invoked.
Access modifier: Public can be accessed by any class.
Private:- can be assessed only by a function in a class (inaccessible outside the class ).
Protected: It is can inaccessible outside the class but can be accessed by a subclass of that class.
Friend class: A friend class can access private and protected members of other class in which it is declared as friend.
Ex: friend class B;
Next Page read for Click Here
0 comments:
If you have any doubts,please let me know