Variables | int x = 5; | Declaring a variable |
Data Types | int, float, double, char, string | Common data types in C++ |
Arrays | int arr[5] = {1, 2, 3, 4, 5}; | Declaring an array |
Pointers | int* ptr = &x; | Declaring a pointer |
Functions | void myFunction() { ... } | Defining a function |
If Statements | if (x > 0) { ... } | Basic if statement |
Loops | for (int i = 0; i < 5; i++) { ... } | For loop |
While Loops | while (x < 5) { ... } | While loop |
Switch Statements | switch (x) { case 1: ...; break; } | Switch statement |
Classes | class MyClass { ... }; | Defining a class |
Inheritance | class ChildClass : public ParentClass {} | Inheriting a class |
Exception Handling | try { ... } catch (exception& e) { ... } | Handling exceptions |
File I/O | ifstream file("file.txt"); | Reading from a file |
Constructors/Destructors | MyClass() { ... } ~MyClass() { ... } | Constructor and Destructor |
Namespaces | namespace ns { ... } | Defining a namespace |