c++ - map容器的value_type中的key_type为何是const?
PHPz
PHPz 2017-04-17 12:58:11
0
1
649
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

学习是最好的投资!

répondre à tous(1)
大家讲道理

因为你没办法对一个已经添加进Map当中的K/V对的键进行更改,只能对值进行更改。
如果要对键进行更改,只能删掉这个,然后再添加一个新的。

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!