C++ chapter 1

🟩 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++

  1. Object-Oriented (uses classes & objects)
  2. Simple and Fast (based on C)
  3. Portable (runs on any platform)
  4. Compiled Language (requires compiler)
  5. Reusability through functions and classes
  6. Rich Library of built-in functions
  7. 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 file
  • using namespace std; → allows use of standard C++ features
  • main() → starting point of the program
  • cout → prints output
  • return 0; → ends the program successfully

🔹 4. Difference Between C and C++

FeatureCC++
Programming StyleProceduralObject-Oriented
DataFunctions act on dataData & functions tied as objects
SecurityLess secureMore secure (Encapsulation)
ReusabilityLimitedHigh (via classes)
InheritanceNot supportedSupported

🔹 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)

Leave a Comment

Your email address will not be published. Required fields are marked *