🟩 Chapter 1: Introduction to C++
🔹 1. What is C++?
- C++ is an object-oriented programming language (OOP) developed by Bjarne Stroustrup in 1979 at Bell Labs.
- It is an extension of C, adding classes and objects.
- Known as a middle-level language (supports both high-level and low-level programming).
🔹 2. Features of C++
- Object-Oriented (uses classes & objects)
- Simple and Fast (based on C)
- Portable (runs on any platform)
- Compiled Language (requires compiler)
- Reusability through functions and classes
- Rich Library of built-in functions
- Extensible – new features can be added easily
🔹 3. Structure of a C++ Program
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!";
return 0;
}
Explanation:
#include <iostream> → input/output header fileusing namespace std; → allows use of standard C++ featuresmain() → starting point of the programcout → prints outputreturn 0; → ends the program successfully
🔹 4. Difference Between C and C++
| Feature | C | C++ |
|---|---|---|
| Programming Style | Procedural | Object-Oriented |
| Data | Functions act on data | Data & functions tied as objects |
| Security | Less secure | More secure (Encapsulation) |
| Reusability | Limited | High (via classes) |
| Inheritance | Not supported | Supported |
🔹 5. OOP Concepts
- Class – Blueprint of objects
- Object – Instance of class
- Encapsulation – Wrapping data & functions together
- Abstraction – Hiding internal details
- Inheritance – Acquiring properties of another class
- Polymorphism – Many forms (e.g., function overloading)
