void util::changeState(bool* variable){
if(*variable){ //variable = 1, so change it to 0 (true to false)
//*variable = 0;
*variable = false;
}
else{ //variable = 0, so change it to 1 (false to true)
*variable = 1;
}
}
// The above function could be simplified to something like:
void util::changeState(bool& variable){
variable = ~variable; // Change the state of the value.
}
//Also I would consider returning the value, and passing the value by value.
bool util::changeState(bool variable){
return ~variable;
}
// This way the user can control whether or not to change the value being passed, or to assign the changed value into another variable.
bool bool_value = true;
bool new_bool_value = util::changeState(bool_value);
You have a function with bool values, why are you using 0, 1 instead of true, false?