C++ Notes

OOP in C++

Supports encapsulation, inheritance, polymorphism, and abstraction.

class Animal {
public:
  void speak() { cout << "Sound"; }
};

STL (Standard Template Library)

Includes commonly used data structures like vector, map, set, etc.

#include <vector>
vector<int> v = {1, 2, 3};

Pointers

Variables that store memory addresses. Used for dynamic memory and object manipulation.

int* ptr = &x;

Inheritance

Allows a class to use properties and methods of another class.

class Dog : public Animal { };

File Handling

Use fstream for reading/writing files in C++.

ofstream fout("file.txt");
fout << "Hello";
Can’t find what you're looking for? Request a topic