正確使用STL MAP中Erase函式

2021-07-02 12:14:38 字數 505 閱讀 7455

一切盡在**中。

#include #include 

#include

using

namespace

std ;

int main(void

) }

//正確的寫法

for (itor = m.begin(); itor !=m.end();)

else

}//另乙個正確的寫法,利用erase的返回值,注意,有些版本的stl-map沒有返回值,比如sgi版,但vc版的有

for (itor = m.begin(); itor !=m.end();)

else

}//print m

map::const_iterator citor ;

for (citor = m.begin(); citor != m.end(); ++citor)

getchar() ;

return0;

}

正確使用stl map的erase方法

正確使用stl map的erase方法 stl的map表裡有乙個erase方法用來從乙個map中刪除掉指令的節點 eg map string string maptest typedef map string string iterator iter iter iter maptest.find k...

正確使用stl map的erase方法

先宣告 下面的文章是針對windows的用法,因為std map的erase函式的windows的實現版本是返回乙個std map的迭代器,但是stl標準裡面的該函式的返回值確是 map.erase有3個過載 void erase iterator position size type erase ...

正確使用stl map的erase方法

先宣告 下面的文章是針對windows的用法,因為std map的erase函式的windows的實現版本是返回乙個std map的迭代器,但是stl標準裡面的該函式的返回值確是 map.erase有3個過載 void erase iterator position size type erase ...