C++ Tutorials: Chapter 1. Basic Concepts of OOP - coderforcoders


Sunday, 26 May 2019

C++ Tutorials: Chapter 1. Basic Concepts of OOP

C++ tutorials:

chapter 1:

Basic concepts of C++ programming

These are some of the basic concepts of  C++ programming.

  • Objects
  • Classes
  • Data abstraction
  • Data encapsulation
  • Inheritance
  • Polymorphism
  • Dynamic binding
  • Message passing


Objects are the instances of the class. Using object we can access the members of the class. The program objects represents the real time objects such as a place, person or any elements. Objects are the most useful concept of C++ programming. The Objects will stored in memory in the form of structure like in c programming.

Creating object: Objects must be created before we access the members of the class. It can be created anywhere in the program. The best practice of creating object is inside the main function.  Objects can be created using the following 

                       classname objectname;                                         
                       result student1;                                                 
      where result is a class and student1 is an object of  the class.


Class is a special feature in C++ programming. Classes are the user defined data types which is the combination of one or more types of members. The members of class can only be accessed by using objects of that class. In C++ programming the data is encapsulated by the class.
Creating the class: The class in a C++ program can be created using the keyword class.
                             class classname{
                                 Data members;
                                 Member functions;
        where class is the keyword and classname is the name of your class.

Data Abstraction:

Data abstraction is the most important concept of C++ programming. The abstraction means providing only the  required data without the background or the explanation. It hides all the unnecessary details about the data and provides only the required data.
In real time example, a person  searches something on google and gets the required search result, but he does not know that how really the search mechanism works, this is what  called as the abstraction.

Data Encapsulation:  

Encapsulation is the process of wrapping the data and the functions as a single entity. In C++ programming, using class  we can achieve the data encapsualtion. Class wraps  the data and the functions into a single entity which is the class name. It makes the data and the functions more secured.


Inheritance is the method of accessing the members of another class using objects of another class. The inheritance concept is introduced in C++ programming. Using this concept one class can access the members of another class. In OOP the idea of inheritance is to make the re-usability of the code. we can append any new update to the code without modifying the main code but by just inheriting the same code. This can be achieved by using the concepts of child class. The class which inherits the data is called child class and the class which is being inherited is called parent class.


Polymorphism is an another basic concept of OOP. It is a geek term which means ability to take more than one form. In C++ programming an instance may exhibit different behavior in different cases. This feature of C++ programming helps us to implement operator overloading concepts in our programs. 

Dynamic Binding:

It is also called as late binding. Binding refers to the linking of procedure call to code in response to  the call. In dynamic binding the code associated with the procedure call is not known until the call at run  time. It is associated with polymorphism and inheritance.

Message Passing:  

C++ program consists of multiple objects. One object can communicate with another by using the concepts of message passing. Objects can send or receive messages to or from another object.

No comments:

Post a Comment