04.01 · Lesson
OOP Introduction
Object Oriented Programming
Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance by providing core concepts like inheritance, encapsulation, abstraction, and polymorphism.
Class & Object
Fundamental building blocks of OOP:
- Class: A user-defined data type which defines its properties and its functions. It is the only logical representation of the data. It does not occupy any memory space until an object is instantiated.
- Object: A run-time entity and an instance of the class. It can represent a person, place or any other item. An object can operate on both data members and member functions.
- Memory Allocation: When created using ‘new’, space is allocated in heap and address stored in stack. Without ‘new’, space is not allocated in heap and object contains null value in stack.
class student {
public:
int id;
string name;
int add(int x, int y) { return x + y; }
};
student s = new student(); Item 23 of 28 · updated 2026-10-12