🔹 OOPs (Object-Oriented Programming System) in C++
👉 Definition:
OOPs ek programming paradigm hai jisme hum apne code ko "objects" aur "classes" ke form me organize karte hain.
- Class = Blueprint/template (design)
- Object = Class ka real-world instance (use kiya gaya cheez)
Example:
Car ek class hai (blueprint – car ka design).
MyCar ek object hai (aapki khud ki car jo aap use kar rahe ho).
🔹 OOPs Concepts in C++
- Class & Object
- Class = template (variables + functions)
- Object = class ka real entity
- Encapsulation
- Data (variables) + Functions (methods) ko ek single unit me band karna.
- Example:
private, public, protected keywords.
- Abstraction
- Sirf zaroori details dikhana aur implementation hide karna.
- Example:
cin & cout internally complex hote hain, lekin hum simple use karte hain.
- Inheritance
- Ek class dusri class ke features ko inherit karti hai.
- Example:
Car class se SportsCar class bana sakte ho.
- Polymorphism
- "Many forms" – ek function alag-alag tarike se kaam karega.
- Types: Compile-time (function overloading, operator overloading), Run-time (virtual functions).
🔹 Kyu OOPs padhna zaroori hai?
- Real-world problems solve karne ke liye best approach
- Code real-world entities jaisa lagta hai (BankAccount, Student, Car).
- Code Reusability
- Inheritance aur modular design se same code bar-bar likhne ki zaroorat nahi.
- Scalability aur Maintainability
- Large projects easily manage hote hain.