Answer the question
In order to leave comments, you need to log in
What does the ":" operator do in this case in c++?
Good afternoon! I recently came across this code for creating a button class for Arduino:
//...
class Button
{
public: Button (uint8_t pin, bool pullup = false, uint16_t debounceDelay = 50)
: _pin(pin), _state(LOW), _lastState(LOW),
_lastMillis(0), _debounceDelay(debounceDelay),
_lastDebounceTime(0)
{
if (pullup == true)
{
pinMode(_pin, INPUT_PULLUP);
}
else
{
pinMode(_pin, INPUT);
}
}
//...
:
(line 5) is used here, and in general the whole construction after it. If anyone knows, please tell me what it is, or better just give a link to a reference resource, I will be very grateful. Answer the question
In order to leave comments, you need to log in
This is called the initialization section . In this section, you can independently initialize the fields of the created object even before passing control to the constructor body.
Starting with C++11, you can specify constructor delegation in the initialization section. The selected constructor will also be executed before entering the body of the current constructor.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question