#include <iostream> #include <map> using namespace std; int main() { map<int, string> m; m[0] = "h1"; m[3] = "what"; m.insert(pair<int, string>(4, "love you")); cout<<m[0].c_str()<<endl; cout<<m[3].c_str()<<endl; cout<<m[4].c_str()<<endl; cout<<m[2].c_str()<<endl; // 会产生一个新的元素,即m[2] = "" cout<<m.size()<<endl; // 4 for(map<int, string>::iterator it = m.begin(); it != m.end(); it++) { cout<<it->first<<", "<<it->second.c_str()<<endl; } return 0; }上面的代码在vc.net2005下没有一个warning,但是在vc6下却有94个warning,不知为何?
原文链接: https://www.cnblogs.com/joeblackzqq/archive/2011/02/27/1966579.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/21605
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!