C++ Programming - Notes for BCA
1. Introduction to C++
- Developed by Bjarne Stroustrup.
- Combines Procedural and Object-Oriented Programming.
2. Structure of C++ Program
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!";
return 0;
3. Data Types
- int, float, double, char, bool, string
4. Variables & Constants
int age = 20;
const float PI = 3.14;
5. Input and Output
cin >> variable;
cout << variable;
6. Operators
- Arithmetic: +, -, *, /, %
- Relational: ==, !=, <, >, <=, >=
- Logical: &&, ||, !
7. Control Structures
- if-else, switch-case
- for, while, do-while loops
8. Arrays
int arr[5] = {1, 2, 3, 4, 5};
9. Functions
void greet() { cout << "Hello"; }
10. OOP Concepts
- Class and Object
- Constructor & Destructor
- Inheritance
- Polymorphism
11. File Handling
ofstream fout("file.txt");
fout << "Hello";
12. Templates
template <class T>
T add(T a, T b) { return a + b; }
13. Exception Handling
try { throw "Error"; } catch (...) { cout << "Caught"; }