cplusplus
cplusplus
## **Table of Contents**
1. [Introduction to C++](#1-introduction-to-c)
2. [Setting Up C++](#2-setting-up-c)
3. [C++ Basics](#3-c-basics)
- [Hello World](#hello-world)
- [Operators](#operators)
4. [Control Structures](#4-control-structures)
- [Conditional Statements](#conditional-statements)
- [Loops](#loops)
5. [Functions](#5-functions)
- [Arrays](#arrays)
- [Strings](#strings)
- [Inheritance](#inheritance)
- [Polymorphism](#polymorphism)
9. [File Handling](#9-file-handling)
---
**Key Features:**
- Strongly typed
**Use Cases:**
- System/OS Programming
- Embedded Systems
- High-Frequency Trading
---
```sh
```
```sh
xcode-select --install
```
---
```cpp
#include <iostream>
return 0;
```
```sh
./hello
```
### **Operators**
```cpp
int age;
cout << "You are " << age << " years old." << endl;
```
---
```cpp
} else {
```
### **Loops**
- **`for` Loop**:
```cpp
```
- **`while` Loop**:
```cpp
int i = 0;
while (i < 5) {
i++;
```
- **`do-while` Loop**:
```cpp
int i = 0;
do {
i++;
```
---
## **5. Functions**
```cpp
int add(int a, int b) {
return a + b;
int main() {
return 0;
```
```cpp
```
---
### **Arrays**
```cpp
```
### **Strings**
```cpp
#include <string>
```
---
```cpp
```
```cpp
ref = 20;
```
---
## **8. Object-Oriented Programming (OOP)**
```cpp
class Dog {
public:
string name;
void bark() {
};
int main() {
Dog dog;
dog.name = "Buddy";
return 0;
```
### **Inheritance**
```cpp
class Animal {
public:
};
class Dog : public Animal {
public:
};
```
### **Polymorphism**
```cpp
class Animal {
public:
};
public:
};
```
---
```cpp
#include <fstream>
// Writing to a file
ofstream outFile("example.txt");
outFile.close();
ifstream inFile("example.txt");
string line;
getline(inFile, line);
inFile.close();
```
---
```cpp
#include <stdexcept>
try {
```
---
```cpp
#include <vector>
nums.push_back(4);
```
```cpp
#include <map>
```
---
---
### **Conclusion**
C++ is a powerful language widely used in performance-critical applications. This guide covers
the fundamentals, but mastering C++ requires hands-on practice and exploration of advanced
concepts. Happy coding! 🚀💻