Q:

Setting default value for Bool by reference

How do i assign a default value to a bool that is a reference?
I have a function like this : 
void someFunction(bool a = true, bool& b)
{
 if(a)
   b = false;
 else
   std::cout << "nothings changed" << std::endl;
}

How should i assign the default value to b in this context?
void someFunction(bool a = true, bool& b = false)

will not work. So how should it be done?

A:

You cannot initialize non-const references with values. You need a variable:
bool dummy_variable;

void someFunction(bool a = true, bool& b = dummy_variable)
{
    // ...
}

But it would probably make a lot more sense to simply return the bool:
bool someFunction(bool a = true)
{
    return !a;
}

Then the client can still decide for himself if he wants to ignore the result or not.

