C++ Object Oriented Programming

C++ is a high-level, general purpose object oriented programming language. It was created by Bjarne Stroustrup, a Danish computer scientist, as an extension of C programming language in early 80’s to add support of the Object Oriented Programming (OOP) features. Over time it has been extended to support wide range of programming features and abilities.

Stroustrup, during his PhD days, found the Simula‘s OOP features very useful for large scale software development. But Simula was very slow for most practical purposes. So, he created C++ adding the support of Simula‘s features in C. He chose C because it was fast, portable, general purpose and widely used programming language.

So, the primary motivation of C++ programming language was to support Object Oriented Programming features.

Object Oriented Programming (OOP)

Object Oriented Programming (OOP) is a programming paradigm around the concept of objects. An object contains data (also referred as properties or attributes) and methods (also referred as executions, functions or procedures).

In OOP, the real world entities are modelled as objects. Each object has its own data and access to the related functions. There could be different types of relationships among objects. Like, one object can be derived from another. Or, one object can contain other objects.

Overall, it is a different approach of solving real life problems over procedural programming.

Object Oriented Programming Features

  1. Class and Object: A class is kind of a blueprint that defines what features and functionalities the objects will have where the objects are the instances of the class. Together, they create the backbone of an object oriented programming. Read more.
  2. Inheritance: a mechanism of acquiring properties and behaviors in a class from another classes, also known as parent classes, to increase the code reusability. Read more.
  3. Polymorphism: the same piece of code behaves differently in different situations. The same interface, function or operation, is bound to different object types. Read more.
  4. Abstraction: a design concept of hiding data or implementation wherever possible and expose only the essential parts. Read more.
  5. Encapsulation: binding the related data and functions in a single entity, class. Read more.

Other Important C++ Features

  1. Function overloading: Multiple functions with the same name but different input parameters.
  2. Operator overloading: Giving meaning to an operator for user defined data types.
  3. Function overriding: Different implementations of a function in base and derived classes.
  4. Template function: Single function definition can be used for different data types.
  5. Template class: Single class definition can be used for different data types.
  6. Inline function: Executing the code of a function directly instead of transferring execution into the called function.
  7. Smart pointers: Managing the lifetime of an object automatically.
  8. Method chaining: Calling multiple methods (functions) in a single statement.
  9. Rvalue reference: One of the most significant features introduced in C++11 that enables move semantics and perfect forwarding.

Author: Srikanta

I write here to help the readers learn and understand computer programing, algorithms, networking, OS concepts etc. in a simple way. I have 20 years of working experience in computer networking and industrial automation.


If you also want to contribute, click here.

Leave a Reply

Your email address will not be published. Required fields are marked *

0
0
0
0
0
0