Unit 1 – Introduction to C++ (Detailed Exam Notes)
1. History of C++
C++ was developed by Bjarne Stroustrup in 1979 at AT&T; Bell Labs (USA).
Started as “C with Classes” and became C++ in 1983.
“++” means increment over C.
Standard versions: C++98, C++03, C++11, C++14, C++17, C++20.
Supports both procedural and object-oriented programming.
2. Advantages of C++
- Supports OOP concepts: class, object, inheritance, encapsulation.
- High performance and fast execution.
- Reusable code via inheritance and templates.
- Portable across platforms.
- Standard Template Library (STL).
- Supports dynamic memory (new/delete).
- Used in gaming, OS, compilers, robotics.
3. Difference Between C++ and Old Programming Languages
Programming Approach:
Old: Procedure-oriented.
C++: Object-oriented + procedural.
Data Security:
Old: Less secure, global data.
C++: Encapsulation and access specifiers.
Code Reusability:
Old: Limited.
C++: High—inheritance, templates.
Memory Management:
Old: Static memory.
C++: Dynamic (new/delete).
Flexibility:
Old: No OOP support.
C++: Multi-paradigm.
4. Character Set
Letters A–Z, a–z
Digits 0–9
White spaces: space, tab, newline
Symbols: + - * / % & @ $ _ # {} [] () ; :
Escape sequences: \n, \t, \b
5. Tokens, Identifiers, Keywords, Variables
Tokens: smallest unit.
Identifiers: user-defined names.
Keywords: int, float, if, else, class.
Variables: memory locations to store data.
6. Operators
Arithmetic: + - * / %
Relational: == != < > <= >=
Logical: && || !
Assignment: = += -=
Increment/Decrement: ++ --
Bitwise: & | ^ << >>
Conditional: ? :
Sizeof: sizeof()
7. Operator Precedence & Associativity
High → Low: () → ++ -- → * / % → + - → relational → == != → && → || → assignment
Associativity:
Left to Right: * / %, + -, < >, &&, ||
Right to Left: =, +=, !, ++ --