这段代码让我发疯:
#include<iostream>
#include<string>
int main()
{
std::string test = "foo";
try
{
throw test;
}
catch (const int &x)
{
std::cout << "int " << x << "\n";
}
catch (const double &x)
{
std::cout << "double " << x << "\n";
}
catch (const std::string &x)
{
std::cout << "string " << x << "\n";
}
return 0;
}
这里没有什么疯狂的。但是输出...
int 7675456
我在我的 linux VM、GDB online 和 repl-it 上尝试过它,它工作正常。我的意思是我有我所期望的:
string foo
我从不在这里发帖,因为我总能找到解决方案。但这一次,我似乎找不到正确的方法来询问谷歌,我只是迷路了。有人有线索吗?
Windows 10 和我使用 MinGW