c++ unordered_map

unordered_map key无法取得时的的默认值

int main() {
    unordered_map m1;
    unordered_map m2;
    unordered_map m3;
    
    cout << (m1["a"] == "") << endl; // output 1
    cout << (m2["a"] == false) << endl; // output 1
    cout << (m3["a"] == 0) << endl; // output 1
}
c++ unordered_map_第1张图片
output

你可能感兴趣的:(c++ unordered_map)