C++ Programming – Complete Notes (Exam
Oriented)
1. Introduction to C++
C++ is an object-oriented programming language developed by Bjarne Stroustrup. It is an extension of the
C language with OOP features.
Features of C++
• Object-Oriented
• Platform independent
• Fast execution
• Supports low-level and high-level programming
• Rich standard library
Applications of C++
• System software
• Game development
• Embedded systems
• Competitive programming
• GUI applications
2. Structure of a C++ Program
#include <iostream>
using namespace std;
int main() {
cout << "Hello World";
return 0;
}
Explanation
• #include : Header file inclusion
• iostream : Input-output stream
• main() : Program execution starts here
1
3. Tokens in C++
• Keywords
• Identifiers
• Constants
• Operators
• Special symbols
4. Data Types in C++
Basic Data Types
• int
• float
• double
• char
• bool
Derived Data Types
• Array
• Pointer
• Reference
User Defined Data Types
• struct
• union
• enum
• class
5. Variables and Constants
• Variable: Stores data
• Constant: Fixed value ( const keyword)
6. Operators in C++
Types of Operators
• Arithmetic
• Relational
• Logical
2
• Assignment
• Increment / Decrement
• Bitwise
• Ternary
7. Input and Output in C++
cin >> x;
cout << x;
8. Control Statements
Decision Making
• if
• if-else
• switch
Looping
• for
• while
• do-while
9. Functions in C++
Types of Functions
• Built-in
• User-defined
Function Types
• Call by value
• Call by reference
10. Arrays
• One-dimensional array
• Two-dimensional array
3
Example:
int a[5] = {1,2,3,4,5};
11. Strings in C++
• C-style strings
• String class ( string )
12. Pointers
• Pointer declaration
• Pointer arithmetic
• Pointer to pointer
13. Object Oriented Programming Concepts
Class and Object
class Student {
public:
int roll;
void display() {
cout << roll;
}
};
OOP Concepts
• Encapsulation
• Abstraction
• Inheritance
• Polymorphism
14. Constructors and Destructors
• Constructor: Initializes object
• Destructor: Destroys object
4
Types: - Default constructor - Parameterized constructor - Copy constructor
15. Inheritance
Types
• Single
• Multiple
• Multilevel
• Hierarchical
• Hybrid
16. Polymorphism
• Function overloading
• Operator overloading
• Virtual functions
17. Templates
• Function templates
• Class templates
18. Exception Handling
try {
// code
}
catch(...) {
// error handling
}
19. File Handling in C++
• ifstream
• ofstream
• fstream
5
20. Standard Template Library (STL)
Components
• Containers (vector, list, map)
• Algorithms
• Iterators
21. Dynamic Memory Allocation
• new
• delete
22. Namespaces
• Used to avoid name conflicts
23. Inline Functions
• Reduces function call overhead
24. Virtual Functions
• Runtime polymorphism
25. Advantages of C++
• Reusable code
• Faster execution
• Object-oriented approach
26. Disadvantages of C++
• Complex syntax
• No automatic garbage collection
6
27. Summary
C++ is a powerful programming language widely used in system-level programming and competitive
coding.
These notes are perfect for [Link] / Diploma / University Semester Exams.