模板套模板~~


















posted on 2006-03-22 00:06 那誰 閱讀(1695) 評論(5) 編輯 收藏 引用 所屬分類: C\C++
隨筆 - 210, 文章 - 0, 評論 - 1183, 引用 - 0
|
模板套模板~~![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() posted on 2006-03-22 00:06 那誰 閱讀(1695) 評論(5) 編輯 收藏 引用 所屬分類: C\C++ 評論# re: 模板套模板~~ 回復 更多評論#include <iostream>#include <map> #include <string> using std::map; using std::cout; using std::endl; using std::string; template<class T1,class T2> void PrintMap(map<T1,T2 >& maptemp,string tempstr = "") { cout<<tempstr <<endl; typename map<T1,T2 >::const_iterator pos; for (pos = maptemp.begin();pos != maptemp.end();++pos) { cout<<"map[" <<pos->first <<"]=" <<pos->second <<" "; } } int main(void) { map<string,int> map1; map<string,map<string,int> > map2; map1["string"] = 2; map2["string2"] = map1; PrintMap<string,int>(map1,"map1"); return 0; }
2006-04-07 17:59 | 紅葉摟風
|
||||||||||||||||||||||