Simple question: How to assign defalut value to bool& ?
The following code is correct and simple
Code:
void foo(bool& valid)
{
valid = true;
return;
}
void foo2(string& str)
{
str = "abc";
return;
}
void main()
{
bool valid;
foo(valid);
string str;
foo2(str);
return;
}
Now what if I want give bool& and string& a default value so that someone can call foo() and foo2() without parameters
Code:
void foo(bool& valid = bool(true) )
{
valid = true;
return;
}
void foo2(string& str=string(""))
{
str = "abc";
return;
}
void main()
{
bool valid;
foo();
foo2();
return;
}
Why it doesn't work?