Skip to content

C++

Last update: 05. March 2023 (Created: 19. February 2023)

C++

Static Analysis

cppcheck

Build

C++ can be built with CMake.

Documentation

Doxygen can generate documentation from C++ source code.

Callbacks

Smart Pointers

Header Files

Includes

// See: https://stackoverflow.com/a/32606280
#include <cstdio> // Should be used, because everything wrapped in std namespace.
#include <stdio.h> // Should not be used, because everything in global namespace.

Exceptions

#include <stdexcept>

try
{
    // Code that might throw an exception.
}
catch (std::exception& exception)
{
    // Code to deal with the exception.
}

Macros

  • __func__ gives the name of the current function (with class name). Useful for logging.

Arguments

int main(int argc, char** argv)
{
    // Easy way
    std::vector<std::string> v(argv, argv + argc);
    // Loop through arguments
}