- 它返回什么
test["hello"]? - 如果我们调用 会发生什么
fun(test["hello"]),但在函数内部fun我们没有赋值,然后我们调用test.find("hello"). 我们有元素吗?如果有,那里会有什么(零,垃圾......)?
代码:
void fun(int& val) {
val = 900;
}
int main()
{
std::unordered_map<std::string, int> test;
fun(test["hello"]);
return 0;
}
test["hello"]将返回对键值的引用hello;如果没有,它将使用默认值(零)创建。已找到,值为 0。
unordered_map我不明白为什么不 1.在书本或网上阅读它,以及 2. 为什么不编译一些简单的测试代码看看会发生什么?