What is Object Oriented Programming with Example?
Many beginners ask this question at first. In simple terms, OOP is a programming paradigm where software is built using classes and objects rather than only functions.
A class acts as a blueprint, while objects are instances created from that blueprint. For example, consider a student record system. Instead of writing separate functions for marks, attendance, and reports, you can design a Student class that handles everything related to a student.
#include
using namespace std;
class Student {
string name;
int marks;
public:
void setData(string n, int m) {
name = n;
marks = m;
}
void display() {
cout << name << " scored " << marks << endl;
}
};
int main() {
Student s1;
s1.setData("Ankit", 88);
s1.display();
}
This example clearly shows how data and behavior stay together inside one logical unit, improving clarity and maintainability.

Why Object Oriented Programming is Important
As applications grow larger, procedural code becomes harder to manage. Global variables, repeated logic, and tightly coupled functions often create errors and increase maintenance costs. OOP solves these problems by promoting modular programming and separation of responsibilities.
Key benefits include:
- improved code reusability
- better security through data hiding
- easier debugging and testing
- scalable architecture for large projects
Because of these advantages, OOP is widely used in enterprise software, game development, automation systems, and embedded firmware.
Core OOP Concepts in C++
To understand OOP concepts in C++, it is important to learn the core principles that form the foundation of object-oriented design. These concepts help create reliable and efficient applications.
Classes and Objects
A class defines the structure and behavior of an entity, while an object represents the actual instance with memory allocation. Multiple objects can be created from a single class, making the design reusable and efficient.
For example, a Vehicle class can be used to create car, bus, or bike objects without rewriting code.
Encapsulation in OOP
Encapsulation in OOP refers to binding data and methods together while restricting direct access to internal variables. This protects data from accidental changes and ensures controlled interaction.
class Account {
private:
double balance;
public:
void deposit(double amt) {
balance += amt;
}
double getBalance() {
return balance;
}
}Here, the balance cannot be modified directly. This improves safety and reliability, which is especially important in banking systems, medical devices, and embedded controllers.
Abstraction
Abstraction means hiding internal implementation details and exposing only necessary features. Users focus on what the system does rather than how it works internally. This reduces complexity and makes large projects easier to understand.
For example, calling a function like add() performs a calculation without exposing the underlying logic. The same principle applies when designing hardware drivers or communication modules.

Polymorphism
Polymorphism allows a single interface to perform multiple behaviors. The same function can behave differently depending on the object that uses it. This flexibility makes applications easier to extend.
class Animal {
public:
virtual void sound() {
cout << "Animal sound\n";
}
};
class Dog : public Animal {
public:
void sound() override {
cout << "Dog barks\n";
}
}This feature is commonly used in simulations, robotics, and interactive systems.
Inheritance
Inheritance enables one class to reuse properties and behavior from another class. It reduces duplication and speeds up development.
class Vehicle {
public:
void start() {
cout << "Vehicle started\n";
}
}
class Car : public Vehicle {
};The Car automatically inherits the start function, demonstrating efficient code reuse.
Difference Between Procedural and Object Oriented Programming
Understanding the difference between procedural and object oriented programming helps developers choose the right approach for their projects.
| Feature | Procedural | Object-Oriented |
| Focus | Functions | Objects |
| Structure | Sequential | Modular |
| Reusability | Limited | High |
| Security | Low | High |
| Maintenance | Difficult | Easier |
| Scalability | Limited | Excellent |
While procedural programming may work for small tasks, OOP is better suited for complex and long-term applications.
Real World Examples of OOP
The true value of OOP becomes clear when applied to practical systems. Many modern technologies rely on object-oriented design to handle complexity efficiently.
Common real world examples of OOP include:
- banking and ATM software
- hospital management systems
- smart home automation
- automotive control units
- IoT and sensor-based devices
In embedded systems, engineers often design separate classes for sensors, communication interfaces, and actuators. This modular structure improves testing, reliability, and system performance.
Final Thoughts
Mastering object oriented programming concepts is essential for building professional software and embedded applications. OOP promotes modular design, reusable components, and maintainable architecture, all of which are critical for modern development. Principles such as encapsulation, abstraction, inheritance, and polymorphism allow developers to create systems that are both flexible and robust.
Whether you are learning C++ through an object oriented programming tutorial or developing real-time firmware, applying these concepts consistently will help you write clean, efficient, and industry-ready code. At IIES Bangalore, students practice these OOP principles through hands-on projects and real-time embedded system training, enabling them to confidently design scalable applications and solve complex engineering problems effectively.
