C++mapの3つの異なる挿入要素の方法
1626 ワード
Talk is cheap. Show you the code!
実行結果:
上記の3つの違いは何ですか?
最初の2つはいずれもinsertを用いており,何の違いもないが,3つ目の違いはデータの挿入に集合の一意性という概念にかかわる.すなわちmapにこのキーワードがある場合、insert操作は挿入できません.しかし、配列で元のデータを直接上書きします.
#include
#include
実行結果:
1 liMing
2 wanglei
3 pang
Insert failure!
上記の3つの違いは何ですか?
最初の2つはいずれもinsertを用いており,何の違いもないが,3つ目の違いはデータの挿入に集合の一意性という概念にかかわる.すなわちmapにこのキーワードがある場合、insert操作は挿入できません.しかし、配列で元のデータを直接上書きします.
#include
#include