C++ Exam-Ready Notes (Detailed Version)
Prepared from 160-slide presentation, rewritten into ~30 pages of exam-focused notes.
1. Introduction to C++
C++ is an Object-Oriented Programming (OOP) language developed by Bjarne Stroustrup at AT&T;
Bell Labs. It was originally known as 'C with classes' and is an extension of the C language.
Key Features:
• Supports classes, objects, operator overloading, function overloading, polymorphism.
• Follows OOP principles: abstraction, encapsulation, inheritance, polymorphism.
• Backward compatible: C programs can run in C++ compilers.
• Programs are easy to maintain, implement and expand.
**Exam Answer Style:**
C++ is an OOP language evolved from C. It supports classes, objects, polymorphism, operator
overloading, and inheritance. It allows modular programming and better data security compared to
C.
2. POP vs OOP
Procedure-Oriented Programming (POP) and Object-Oriented Programming (OOP) are two
different approaches.
• POP: Focus on procedures/functions. OOP: Focus on data (objects).
• POP: Global data accessible by functions. OOP: Data hidden inside objects (encapsulation).
• POP: Top-down approach. OOP: Bottom-up approach.
• POP: Difficult to modify/maintain large programs. OOP: Easy to extend using inheritance.
**Exam Answer Style:**
POP emphasizes functions and uses top-down design, whereas OOP emphasizes data, uses
bottom-up design, and allows data hiding and reusability through inheritance.
3. Tokens in C++
Tokens are the smallest individual units in a C++ program.
• Keywords → e.g., int, float, return.
• Identifiers → Names of variables, functions, classes.
• Constants → Fixed values (e.g., 3.14, 100).
• Strings → Sequence of characters enclosed in double quotes.
• Operators → Symbols like +, -, *, /, etc.
**Exam Answer Style:**
A token is the smallest element in a program. Types include Keywords, Identifiers, Constants,
Strings, and Operators.
4. Identifiers
Identifiers are names given to variables, functions, arrays, classes, etc.
• Include alphabets, digits, underscores (_).
• Cannot start with a digit.
• Case-sensitive (Sum ≠ sum).
• Cannot use reserved keywords (e.g., int, float).
• No length limit but should be meaningful.
**Exam Answer Style:**
Identifiers are the user-defined names in C++ programs. Rules: cannot start with digit,
case-sensitive, keywords not allowed, can use alphabets/digits/underscore.
5. Data Types in C++
Data types specify the type of data stored in a variable.
• Built-in (Primary) → int, char, float, double, void.
• User-Defined → struct, union, class, enum.
• Derived → array, function, pointer.
**Exam Answer Style:**
Data types are categories of data in C++. They are classified as Built-in, User-Defined, and
Derived.