<分区>
如何将这段代码更改为有效代码?!
#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;
}
请注意,我想使用&b
的引用调用方法。