CodeNebula
897+ concepts · C++ and Go

All Concepts

Browse, search, and filter the complete C++ and Go reference. Hover any card to see code, click to dive deeper.

897 results
766 C++/69 Go
C++98core

Basic Types

Fundamental data types like integers, floating-point numbers, characters, and booleans store basic values.

beginnerflip for code
1
int x = 10; float y = 3.14;
C++98core

Enumerations (Unscoped Enums)

Named integer constants grouped under a type, providing meaningful names for sets of related values.

beginnerflip for code
1
enum Color { Red, Green, Blue }; Color c = Green;
C++98core

Unions

A type where all members share the same memory location, holding only one member's value at a time.

beginnerflip for code
1
union Data { int i; float f; }; Data d; d.i = 42;
C++98core

Bitfields

Struct members with exact bit widths, enabling compact storage of flags and small values.

beginnerflip for code
1
struct Flags { unsigned int bold : 1; unsigned int italic : 1; };
C++98core

sizeof Operator

Returns the size in bytes of a type or object at compile time.

beginnerflip for code
1
int size = sizeof(int); // typically 4
C++98core

Pointers

Variables that store memory addresses, enabling direct memory access.

beginnerflip for code
1
int x = 10; int* ptr = &x;
C++98core

References

Aliases for existing variables, providing another name to access the same data.

beginnerflip for code
1
int x = 10; int& ref = x;
C++98core

Arrays

Fixed-size collections of elements of the same type, stored contiguously.

beginnerflip for code
1
int arr[5] = {1, 2, 3, 4, 5};
C++98core

Functions

Reusable code blocks that perform tasks, accepting parameters and returning values.

beginnerflip for code
1
int add(int a, int b) { return a + b; }
C++98core

Function Overloading

Multiple functions with the same name but different parameters.

beginnerflip for code
1
void print(int x) {} void print(float x) {}
C++98core

Default Arguments

Parameter values automatically used when the caller omits them from a function call.

beginnerflip for code
1
void log(const char* msg, int level = 1) {}
C++98core

Inline Functions

A hint to the compiler to expand the function body at each call site, avoiding function call overhead.

beginnerflip for code
1
inline int square(int x) { return x * x; }
C++98core

Function Pointers

Pointers that store the address of a function, enabling dynamic function dispatch and callbacks.

beginnerflip for code
1
void greet() {} void (*fptr)() = &greet; fptr();
C++98core

Pointers to Members

Pointers that refer to a specific data member or member function of a class.

beginnerflip for code
1
struct S { int x; }; int S::*p = &S::x; S s; s.*p = 42;
C++98core

Classes

User-defined types combining data and functions to model entities.

beginnerflip for code
1
class Car { public: int speed; void drive() {}; };
C++98core

Objects

Instances of classes, representing specific entities.

beginnerflip for code
1
Car myCar; myCar.speed = 100;
C++98core

Constructors

Special functions called during object creation to initialize data.

beginnerflip for code
1
class Account { public: Account(int bal) {} };
C++98core

Copy Constructor

A special constructor that creates a new object as a copy of an existing object of the same type.

beginnerflip for code
1
class Widget { public: Widget(const Widget& other) {} };
C++98core

Destructors

Special functions called when an object is destroyed to clean up resources.

beginnerflip for code
1
class File { public: ~File() {} };
C++98core

Copy Assignment Operator

An overloaded `operator=` that assigns one object's state to another existing object of the same type.

beginnerflip for code
1
class Config { public: Config& operator=(const Config& other) { return *this; } };
C++98core

Conversion Functions

Member functions that define implicit or explicit conversions from a class type to another type.

beginnerflip for code
1
class Fraction { public: operator double() const { return 0.5; } };
C++98core

Inheritance

A class inherits properties from one base class.

beginnerflip for code
1
class Car {}; class SportsCar : public Car {};
C++98core

Polymorphism

Treats objects of different types as a common base type.

beginnerflip for code
1
class Shape { virtual void draw() {} };
C++98core

Virtual Functions

Base class functions overridden by derived classes for dynamic dispatch.

beginnerflip for code
1
class Enemy { virtual void attack() {} };
C++98core

Pure Virtual Functions

Virtual functions declared with `= 0`, making a class abstract.

beginnerflip for code
1
class Shape { virtual void draw() = 0; };
C++98core

Abstract Classes

Classes with pure virtual functions that cannot be instantiated.

beginnerflip for code
1
class Vehicle { virtual void move() = 0; };
C++98core

Encapsulation

Hides data using access specifiers to control access.

beginnerflip for code
1
class Account { private: int balance; public: int getBalance() {} };
C++98core

Access Specifiers

`public`, `private`, and `protected` control member visibility.

beginnerflip for code
1
class Player { private: int health; public: void move() {} };
C++98core

Friend Functions

Non-member functions granted access to a class’s private members.

beginnerflip for code
1
class Data { friend void log(Data&); };
C++98core

Friend Classes

A class granted access to another class’s private members.

beginnerflip for code
1
class GameObject { friend class Renderer; };
C++98core

Nested Classes

A class defined inside the scope of another class, typically used as an implementation detail.

beginnerflip for code
1
class List { class Node { int data; Node* next; }; };
C++98core

Local Classes

A class defined inside a function body, scoped to that function only.

beginnerflip for code
1
void process() { class Helper { public: void run() {} }; Helper h; h.run(); }
C++98core

Operator Overloading

Redefines operators (e.g., +, ==) for user-defined types.

beginnerflip for code
1
class Vector2D { Vector2D operator+(Vector2D& other) {} };
C++98core

Templates

Functions that work with any data type via a template parameter.

beginnerflip for code
1
template<typename T> T max(T a, T b) { return a > b ? a : b; }
C++98core

Exception Handling

Handles errors using `try`, `catch`, and `throw`.

beginnerflip for code
1
try { throw "Error"; } catch(const char* msg) {}
C++98core

Namespaces

Groups related code to avoid name conflicts.

beginnerflip for code
1
namespace Utils { void func() {} }
C++98core

Scope Resolution Operator (::)

Accesses members of a namespace, class, or enum, and resolves ambiguity in nested scopes.

beginnerflip for code
1
2
namespace Math { int add(int a, int b) { return a + b; } }
int result = Math::add(1, 2);
C++98core

Dynamic Memory Management

Allocates and deallocates memory at runtime using `new` and `delete`.

beginnerflip for code
1
int* ptr = new int; delete ptr;
C++98core

Type Casting

Converts between types using `static_cast`, `dynamic_cast`, etc.

beginnerflip for code
1
Base* b; Derived* d = dynamic_cast<Derived*>(b);
C++98core

Run-Time Type Information (RTTI)

Identifies object types at runtime using `typeid` or `dynamic_cast`.

beginnerflip for code
1
#include <typeinfo> typeid(obj).name();
C++98core

Typeid

Operator to get type information of an object at runtime.

beginnerflip for code
1
#include <typeinfo> cout << typeid(int).name();
C++98core

Storage Class Specifiers

Keywords (`static`, `extern`, `register`) that control the storage duration, linkage, and lifetime of variables.

beginnerflip for code
1
void counter() { static int count = 0; count++; }
C++98core

Volatile Keyword

Tells the compiler that a variable may change at any time, preventing optimization of reads/writes.

beginnerflip for code
1
volatile int* status_reg = (volatile int*)0x40000;
C++98core

Mutable Keyword

Allows a data member to be modified even inside a `const` member function.

beginnerflip for code
1
class Data { mutable int cache; public: int get() const { cache = 42; return cache; } };
C++98core

Conditional (Ternary) Operator

An inline expression `condition ? true_value : false_value` that returns one of two values based on a condition.

beginnerflip for code
1
int x = 10; int abs_x = (x >= 0) ? x : -x;
C++98core

Comma Operator

Evaluates two expressions in sequence, discards the first result, and returns the second.

beginnerflip for code
1
for (int i = 0, j = 10; i < j; i++, j--) {}
C++98core

Preprocessor Directives

Compile-time instructions (`#define`, `#include`, `#ifdef`, `#ifndef`, `#pragma`) that control text substitution and conditional compilation.

beginnerflip for code
1
2
3
4
#ifndef MY_HEADER_H
#define MY_HEADER_H
// declarations
#endif
C++98stl

std::vector

Dynamic array that grows or shrinks as needed.

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