How does this do what it does (C++ classes, use of colon)

C-style arrays are a mess, if you use a std::array, you can just pass it to the constructor by value or reference-to-const and initialize the member like any normal variable:

class Signal
{
  protected:
    std::array<uint8_t, numPins> pins;
    uint8_t value;

    // initialize use a reference to an array
    Signal(const std::array<uint8_t, numPins> &pins) : pins(pins) {}
1 Like