void g(int& a)
{
std::cout<<"int&\n";
}
void g(int a)
{
std::cout<<"int\n";
}
int main()
{
int a = 2;
g(a); //won't compile (at least under MSVC 2012)
std::cin.ignore();
}
有没有办法在这里避免模棱两可的调用错误?就像是g( static_cast<int&>(a) );