PieterP:
PushButton(uint8_t pin) // Constructor (executes when a PushButton object is created)
: pin(pin) { // remember the push button pin
pinMode(pin, INPUT_PULLUP); // enable the internal pull-up resistor
}
You should not place hardware related setup (like pinMode) in a constructor.
It could be run before the Arduino's init function, so it may not work.
Such initializations belong to a function often called begin() called from setup,
which is guaranteed to be run after init.