Part 11 - headers vs source files

header files

Headers contain declaration of the functions/classes/enums/whetever that is supposed to be accessible by others.

Protip: use #pragma once in header files to prevent adding same header multiple times. It’s same as standard include guards in C, just shorter.

#pragma once

class Color
    Color(float r, float g, float b, float a = 1.0f);

    float red, green, blue, alpha;

source files

They actually specify how stuff is headers work.

#include "Color.hpp"

    : red(0), green(0), blue(0), alpha(0)

Color::Color(float r, float g, float b, float a)
    : red(r), green(g), blue(b), alpha(a)