c++ - map容器的value_type中的key_type为何是const?
PHPz
PHPz 2017-04-17 12:58:11
0
1
711
map<string, int>::key_type v1;//v1 string
map<string, int>::value_type v2;//v2 pair<const string,int>

为何后者的key_type 是const?而 mapped_type 又不是const?

PHPz
PHPz

学习是最好的投资!

reply all(1)
大家讲道理

Because you cannot change the key of a K/V pair that has been added to the Map, you can only change the value.
If you want to make changes to the key, you can only delete this one and add a new one.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template