Introduction to Object Oriented Programming using C++

Written by Hamza on. Posted in C++

This article is the first in a series which will be centered around object oriented programming in C++ for beginners. However, the hope is that programmers of a more intermediate to advanced level who are looking to refresh their basic object oriented programming skills. First we start with an introduction to object oriented programming using C++. 

What is Object Oriented Programming

C++ is an object oriented programming language. The power of OOP lies in the fact that it brings programming as close to the real world as possible. In ordinary terms, we know that there are objects all around us. The desk on which your computer is placed, the chair in which you sit, the tree outside your window etc, are all objects and can be treated as separate units.  Object oriented programming bases itself in the creation of separate units or objects in our code, that can be treated and dealt with separately and which has its own individual characteristics. In C++, this is done by using classes.


Advantages of Object Oriented Programming

The advantage of using objects over simply using procedural functions in our code is that objects tend to bring their methods and functionality with them automatically wherever they go. This is a huge help in more advanced C++ programming concepts. Leading on from this, making small changes in your class makes a sweeping change in your entire code, making it easier to modify and edit programs. The greatest advantage of using OOP is that we can set a clearly defined object with a clearly defined interface in our code without revealing how its functionality is implemented. This makes our code more safe and reliable, and easy to change.

How to make and create objects

Objects are made after creating classes. A class in C++ is basically a collection of some variable data members of different data types along with the functions that can be performed on them. After a class is created, it becomes a sort of data type in our code and we can use the class’s name as we use other data types like ‘int’ or ‘char’. The variables created using these classes are called objects.

Henceforth, we will venture into deeper realms of object oriented programming in C++. There are many concepts associated with it including operator overloading and generic programming. To start learning about classes in C++, click here.

Tags: , , ,