Topic 1 of 83
Introduction
Overview
C++ was created by Bjarne Stroustrup in 1979 as an extension of the C programming language ('C with Classes'). It adds object-oriented features while maintaining C's speed and low-level memory control, making it perfect for systems software, game engines, and high-performance applications.
Syntax
cpp
1// C++ is an evolution of C
2// Key additions over C include:
3// - Classes and Objects (OOP)
4// - Templates (Generic Programming)
5// - Exception Handling
6// - Standard Template Library (STL)Common Pitfalls
- Assuming C++ is exactly the same as C. While C++ is almost a superset of C, there are subtle differences in type checking and keywords.
Interview Tips
- Be prepared to explain the difference between C and C++ (e.g., C++ supports OOP and function overloading, C does not).
- Understand why C++ is a 'compiled' language and how the compilation process works (Preprocessing -> Compilation -> Assembly -> Linking).
Real-World Example
Understanding the evolution from C to C++.
example
cpp
1/*
2 C approach: Procedural
3 struct Car { int speed; };
4 void accelerate(struct Car* c) { c->speed++; }
5
6 C++ approach: Object-Oriented
7 class Car {
8 private:
9 int speed;
10 public:
11 void accelerate() { speed++; }
12 };
13*/