I've just seen this syntax for a function prototype in C++:
explicit String(unsigned char value, unsigned char base=10);
I haven't seen this before, but am I right in assuming it sets base
to 10 regardless of what you call it with?
The default parameter, called base
will take whatever value you send it, or the value 10, if you leave it off, e.g. by calling
String(0);
Given that you can call it with just one parameter, since the second can be defaulted, a constructor can be marked as explicit
. This means it won't create a temporary from an unsigned char
without you noticing, you have to explicitly call the constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With