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
// C++ is an evolution of C
// Key additions over C include:
// - Classes and Objects (OOP)
// - Templates (Generic Programming)
// - Exception Handling
// - 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
/*
C approach: Procedural
struct Car { int speed; };
void accelerate(struct Car* c) { c->speed++; }
C++ approach: Object-Oriented
class Car {
private:
int speed;
public:
void accelerate() { speed++; }
};
*/