You do not understand what const does in this case and how it works.
First of all, in C ++, static member functions cannot be const. The function you show returns a type of "const void" (does it make sense and should the compiler warn - this is another topic).
Secondly, the parameter you are changing is not a constant. If βchangeβ is not a static function and has a βconstβ modifier for the function, the dummy can be changed:
void modify_nonstatic(float &dummy) const { dummy = 1.5f;
If you want the parameter to be const, enter the parameter const:
static void modify(const float &dummy) { dummy = 1.5f;
source share