How can I change this piece of code to a working one?!
#include <iostream>
void foo( bool &b ) // ERROR in passing argument 1 of ‘void foo(bool&)’
{
std::cout << b << '\n';
}
int main()
{
foo( false ); // ERROR invalid initialization of non-const reference of type ‘bool&’ from a temporary of type ‘bool’
return 0;
}
Please note that I want to use call by reference method using &b
.