1. Variables


int x = 10; // integer variable
double y = 20.5; // floating-point variable
char name = 'A'; // character variable

2. Data Types


int, float, char, double, long, short, unsigned

3. Operators


+, -, \*, /, %, ==, !=, >, <, >=, <=, &&, ||, !

4. Control Structures


if (condition) { code }
if (condition) { code } else { code }
switch (expression) { case value: code; break; }
for (init; condition; increment) { code }
while (condition) { code }
do { code } while (condition);

5. Loops


for (int i = 0; i < 10; i++) { code }
while (i < 10) { code; i++; }
do { code; i++; } while (i < 10);

6. Arrays


int scores[] = {90, 80, 70, 60};
char names[] = {'J', 'o', 'h', 'n'};

7. Functions


int add(int a, int b) { return a + b; }
void greet(char name[]) { cout << "Hello, " << name << "!"; }

8. Pointers


int x = 10;
int* ptr = &x; // pointer to x
cout << *ptr; // prints 10

9. Classes


class Person {
private:
string name;
public:
Person(string name) { this->name = name; }
void display() { cout << "Name: " << name; }
};

10. Objects


Person person("John Doe");
person.display(); // prints "Name: John Doe"

11. Inheritance


class Animal {
public:
void sound() { cout << "The animal makes a sound."; }
};
class Dog : public Animal {
public:
void sound() { cout << "The dog barks."; }
};

12. Polymorphism


class Animal {
public:
virtual void sound() { cout << "The animal makes a sound."; }
};
class Dog : public Animal {
public:
void sound() { cout << "The dog barks."; }
};
Animal* animal = new Dog();
animal->sound(); // prints "The dog barks."

13. Encapsulation


class Person {
private:
string name;
public:
Person(string name) { this->name = name; }
string getName() { return name; }
};

14. Abstraction


class Animal {
public:
virtual void sound() = 0;
};
class Dog : public Animal {
public:
void sound() { cout << "The dog barks."; }
};

15. Interface


class Printable {
public:
virtual void print() = 0;
};
class Document : public Printable {
public:
void print() { cout << "Printing document..."; }
};

16. Exception Handling


try { code } catch (exception) { code }

17. File Input/Output


ifstream file("example.txt");
ofstream file("example.txt");

18. Networking


#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

19. Multithreading


#include <pre>
<code>
#include <thread>
void myFunction() { /* code */ }
std::thread t(myFunction);
t.join();

20. Lambda Expressions


auto add = [](int a, int b) { return a + b; };
cout << add(5, 3); // prints 8

21. Smart Pointers


#include <memory>
std::unique_ptr<int> ptr(new int(10));

22. Move Semantics


std::string str1 = "Hello";
std::string str2 = std::move(str1);

23. Range-based for Loop


std::vector<int> vec = {1, 2, 3, 4};
for (int x : vec) { cout << x; }

24. Type Inference


auto x = 10; // x is inferred as int

25. Static Members


class MyClass {
static int count;
};

26. Constexpr


constexpr int square(int x) { return x * x; }

27. Template Functions


template <typename T>
T add(T a, T b) { return a + b; }

28. Template Classes


template <typename T>
class MyClass {
T value;
};

29. Default Arguments


void func(int x, int y = 10) { /* code */ }

30. Function Overloading


void func(int x) { /* code */ }
void func(double y) { /* code */ }

31. Operator Overloading


class Complex {
public:
Complex operator+(const Complex& other) { /* code */ }
};

32. Friend Functions


class MyClass {
friend void myFunction(MyClass& obj);
};

33. Namespaces


namespace MyNamespace {
int x;
}

34. Using Declarations


using namespace std;

35. Using Statements


using std::cout;

36. Enum Classes


enum class Color { Red, Green, Blue };

37. Bit Fields


struct MyStruct {
unsigned int a : 1;
unsigned int b : 2;
};

38. Variadic Templates


template<typename... Args>
void func(Args... args) { /* code */ }

39. std::vector


#include <vector>
std::vector<int> vec = {1, 2, 3};

40. std::map


#include <map>
std::map<int, std::string> myMap;

41. std::set


#include <set>
std::set<int> mySet;

42. std::unordered_map


#include <unordered_map>
std::unordered_map<int, std::string> myMap;

43. std::unordered_set


#include <unordered_set>
std::unordered_set<int> mySet;

44. std::deque


#include <deque std::deque<int> myDeque;

45. std::list


#include <list>
std::list<int> myList;

46. std::array


#include <array>
std::array<int, 5> myArray = {1, 2, 3, 4, 5};

47. std::string


#include <string>
std::string str = "Hello, World!";

48. std::unique_ptr


#include <memory>
std::unique_ptr<int> ptr(new int(10));

49. std::shared_ptr


#include <memory>
std::shared_ptr<int> ptr = std::make_shared<int>(10);

50. std::weak_ptr


#include <memory>
std::weak_ptr<int> weakPtr = ptr;

51. std::function


#include <functional>
std::function<int(int, int)> add = [](int a, int b) { return a + b; };

52. std::bind


#include <functional>
auto boundFunc = std::bind(add, 5, std::placeholders::_1);

53. std::thread


#include <thread>
void myFunction() { /* code */ }
std::thread t(myFunction);
t.join();

54. std::mutex


#include <mutex>
std::mutex mtx;
mtx.lock();
// critical section
mtx.unlock();

55. std::condition_variable


#include <condition_variable>
std::condition_variable cv;
cv.wait(lock);
// notify
cv.notify_one();

56. std::atomic


#include <atomic>
std::atomic<int> count(0);
count++;

57. std::optional


#include <optional>
std::optional<int> opt;

58. std::variant


#include <variant>
std::variant<int, std::string> var;

59. std::any


#include <any>
std::any a = 10;

60. std::chrono


#include <chrono>
auto start = std::chrono::high_resolution_clock::now();
// code
auto end = std::chrono::high_resolution_clock::now();

61. std::filesystem


#include <filesystem>
std::filesystem::path p("example.txt");

62. std::initializer_list


#include <initializer_list>
void func(std::initializer_list<int> list) { /* code */ }

63. std::array


#include <array>
std::array<int, 5> arr = {1, 2, 3, 4, 5};

64. std::tuple


#include <tuple>
std::tuple<int, double, std::string> t(1, 2.0, "Hello");

65. std::get


std::get<0>(t); // gets the first element of the tuple

66. std::make_tuple


auto t = std::make_tuple(1, 2.0, "Hello");

67. std::tie


auto [a, b, c] = std::tie(1, 2, 3); // unpacking tuple

68. std::sort


#include <algorithm>
std::vector<int> vec = {3, 1, 2};
std::sort(vec.begin(), vec.end());

69. std::find


#include <algorithm>
auto it = std::find(vec.begin(), vec.end(), 2);

70. std::copy


#include <algorithm>
std::vector<int> dest(3);
std::copy(vec.begin(), vec.end(), dest.begin());

71. std::accumulate


#include <numeric>
int sum = std::accumulate(vec.begin(), vec.end(), 0);

72. std::for_each


std::for_each(vec.begin(), vec.end(), [](int x) { cout << x; });

73. std::transform


std::transform(vec.begin(), vec.end(), vec.begin(), [](int x) { return x * 2; });

74. std::remove


vec.erase(std::remove(vec.begin(), vec.end(), 2), vec.end());

75. std::unique


std::vector<int> uniqueVec = {1, 1, 2, 3};
uniqueVec.erase(std::unique(uniqueVec.begin(), uniqueVec.end()), uniqueVec.end());

76. std::reverse


std::reverse(vec.begin(), vec.end());

77. std::shuffle


#include <random>
std::shuffle(vec.begin(), vec.end(), std::default_random_engine());

78. std::setprecision


#include <iomanip>
std::cout << std::setprecision(2) << std::fixed << 3.14159;

79. std::getline


std::string line;
std::getline(std::cin, line);

80. std::stoi


int number = std::stoi("123");

81. std::to_string


std::string str = std::to_string(123);

82. std::ostringstream


#include <sstream>
std::ostringstream oss;
oss << "Value: " << 10;
std::string result = oss.str();

83. std::istringstream


#include <sstream>
std::istringstream iss("10 20");
int a, b;
iss >> a >> b;

84. std::exception


try { /* code */ } catch (const std::exception& e) { std::cout << e.what(); }

85. std::runtime_error


throw std::runtime_error("Error occurred");

86. std::logic_error


throw std::logic_error("Logic error");

87. std::out_of_range


throw std::out_of_range("Out of range");

88. std::invalid_argument


throw std::invalid_argument("Invalid argument");

89. std::vector::push_back


vec.push_back(4);
::po90. p_back -->

std::vector::pop_back


vec.pop_back();

91. std::vector::size


size_t size = vec.size();

92. std::vector::clear


vec.clear();

93. std::map::insert


myMap.insert({1, "One"});

94. std::map::find


auto it = myMap.find(1);
if (it != myMap.end()) { cout << it->second; }

95. std::set::insert


mySet.insert(1);

96. std::set::count


size_t count = mySet.count(1);

97. std::unordered_map::insert


myMap.insert({1, "One"});

98. std::unordered_set::insert


mySet.insert(1);

99. std::deque::push_back


myDeque.push_back(1);

100. std::list::push_back


myList.push_back(1);