All Concepts
Browse, search, and filter the complete C++ and Go reference. Hover any card to see code, click to dive deeper.
Basic Types
Fundamental data types like integers, floating-point numbers, characters, and booleans store basic values.
int x = 10; float y = 3.14;
Enumerations (Unscoped Enums)
Named integer constants grouped under a type, providing meaningful names for sets of related values.
enum Color { Red, Green, Blue }; Color c = Green;Unions
A type where all members share the same memory location, holding only one member's value at a time.
union Data { int i; float f; }; Data d; d.i = 42;Bitfields
Struct members with exact bit widths, enabling compact storage of flags and small values.
struct Flags { unsigned int bold : 1; unsigned int italic : 1; };sizeof Operator
Returns the size in bytes of a type or object at compile time.
int size = sizeof(int); // typically 4
Pointers
Variables that store memory addresses, enabling direct memory access.
int x = 10; int* ptr = &x;
References
Aliases for existing variables, providing another name to access the same data.
int x = 10; int& ref = x;
Arrays
Fixed-size collections of elements of the same type, stored contiguously.
int arr[5] = {1, 2, 3, 4, 5};Functions
Reusable code blocks that perform tasks, accepting parameters and returning values.
int add(int a, int b) { return a + b; }Function Overloading
Multiple functions with the same name but different parameters.
void print(int x) {} void print(float x) {}Default Arguments
Parameter values automatically used when the caller omits them from a function call.
void log(const char* msg, int level = 1) {}Inline Functions
A hint to the compiler to expand the function body at each call site, avoiding function call overhead.
inline int square(int x) { return x * x; }Function Pointers
Pointers that store the address of a function, enabling dynamic function dispatch and callbacks.
void greet() {} void (*fptr)() = &greet; fptr();Pointers to Members
Pointers that refer to a specific data member or member function of a class.
struct S { int x; }; int S::*p = &S::x; S s; s.*p = 42;Classes
User-defined types combining data and functions to model entities.
class Car { public: int speed; void drive() {}; };Objects
Instances of classes, representing specific entities.
Car myCar; myCar.speed = 100;
Constructors
Special functions called during object creation to initialize data.
class Account { public: Account(int bal) {} };Copy Constructor
A special constructor that creates a new object as a copy of an existing object of the same type.
class Widget { public: Widget(const Widget& other) {} };Destructors
Special functions called when an object is destroyed to clean up resources.
class File { public: ~File() {} };Copy Assignment Operator
An overloaded `operator=` that assigns one object's state to another existing object of the same type.
class Config { public: Config& operator=(const Config& other) { return *this; } };Conversion Functions
Member functions that define implicit or explicit conversions from a class type to another type.
class Fraction { public: operator double() const { return 0.5; } };Inheritance
A class inherits properties from one base class.
class Car {}; class SportsCar : public Car {};Polymorphism
Treats objects of different types as a common base type.
class Shape { virtual void draw() {} };Virtual Functions
Base class functions overridden by derived classes for dynamic dispatch.
class Enemy { virtual void attack() {} };Pure Virtual Functions
Virtual functions declared with `= 0`, making a class abstract.
class Shape { virtual void draw() = 0; };Abstract Classes
Classes with pure virtual functions that cannot be instantiated.
class Vehicle { virtual void move() = 0; };Encapsulation
Hides data using access specifiers to control access.
class Account { private: int balance; public: int getBalance() {} };Access Specifiers
`public`, `private`, and `protected` control member visibility.
class Player { private: int health; public: void move() {} };Friend Functions
Non-member functions granted access to a class’s private members.
class Data { friend void log(Data&); };Friend Classes
A class granted access to another class’s private members.
class GameObject { friend class Renderer; };Nested Classes
A class defined inside the scope of another class, typically used as an implementation detail.
class List { class Node { int data; Node* next; }; };Local Classes
A class defined inside a function body, scoped to that function only.
void process() { class Helper { public: void run() {} }; Helper h; h.run(); }Operator Overloading
Redefines operators (e.g., +, ==) for user-defined types.
class Vector2D { Vector2D operator+(Vector2D& other) {} };Templates
Functions that work with any data type via a template parameter.
template<typename T> T max(T a, T b) { return a > b ? a : b; }Exception Handling
Handles errors using `try`, `catch`, and `throw`.
try { throw "Error"; } catch(const char* msg) {}Namespaces
Groups related code to avoid name conflicts.
namespace Utils { void func() {} }Scope Resolution Operator (::)
Accesses members of a namespace, class, or enum, and resolves ambiguity in nested scopes.
namespace Math { int add(int a, int b) { return a + b; } }
int result = Math::add(1, 2);Dynamic Memory Management
Allocates and deallocates memory at runtime using `new` and `delete`.
int* ptr = new int; delete ptr;
Type Casting
Converts between types using `static_cast`, `dynamic_cast`, etc.
Base* b; Derived* d = dynamic_cast<Derived*>(b);
Run-Time Type Information (RTTI)
Identifies object types at runtime using `typeid` or `dynamic_cast`.
#include <typeinfo> typeid(obj).name();
Typeid
Operator to get type information of an object at runtime.
#include <typeinfo> cout << typeid(int).name();
Storage Class Specifiers
Keywords (`static`, `extern`, `register`) that control the storage duration, linkage, and lifetime of variables.
void counter() { static int count = 0; count++; }Volatile Keyword
Tells the compiler that a variable may change at any time, preventing optimization of reads/writes.
volatile int* status_reg = (volatile int*)0x40000;
Mutable Keyword
Allows a data member to be modified even inside a `const` member function.
class Data { mutable int cache; public: int get() const { cache = 42; return cache; } };Conditional (Ternary) Operator
An inline expression `condition ? true_value : false_value` that returns one of two values based on a condition.
int x = 10; int abs_x = (x >= 0) ? x : -x;
Comma Operator
Evaluates two expressions in sequence, discards the first result, and returns the second.
for (int i = 0, j = 10; i < j; i++, j--) {}Preprocessor Directives
Compile-time instructions (`#define`, `#include`, `#ifdef`, `#ifndef`, `#pragma`) that control text substitution and conditional compilation.
#ifndef MY_HEADER_H #define MY_HEADER_H // declarations #endif
std::vector
Dynamic array that grows or shrinks as needed.
#include <vector> std::vector<int> vec = {1, 2, 3};