当map元素值为int类型或者常量时候,默认值为0.
当为string类型时,默认值不明,不显示。
#include <iostream>
#include <map>
using namespace std;
int main(){
map<int,int> table;
table[1]=1;//只初始化了key值为1的value
cout<<table[0]<<endl;
cout<<table[1]<<endl;
return 0;
}
试试当value值是其他类型呢?比如float,char,vector呢?