★★★★为什么下面这段程序有警告??★★★★

hufanxp 2004-03-04 08:45:44
#include <utility>
#include <map>
#include <iomanip>
#include <iostream>

using namespace std;

int main()
{
pair<int,double> p1(10,1.1e-2);
pair<int,double> p2;

p2 = make_pair(10,2.22e-1);
pair<int,double> p3(p1);
cout.precision(3);

cout << "The pair p1 is:(" << p1.first << ", " << p1.second << ")." << endl;
cout << "The pair p2 is:(" << p2.first << ", " << p2.second << ")." << endl;
cout << "The pair p3 is:(" << p3.first << ", " << p3.second << ")." << endl;

//using a pair for a map element;

map<int,int> m1;
map<int,int>::iterator m1_Iter;
typedef pair<int,int> Map_Int_Pair;

m1.insert(Map_Int_Pair(1,10));
m1.insert(Map_Int_Pair(2,20));
m1.insert(Map_Int_Pair(3,30));

cout << "The element pairs of the map m1 are :";
for (m1_Iter = m1.begin(); m1_Iter != m1.end();m1_Iter++)
cout << " (" << m1_Iter->first << ", " << m1_Iter->second << ") ";
cout << ". " << endl;

return 0;
}
...全文
12 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复

还没有回复,快来抢沙发~

相关推荐
发帖
工具平台和程序库
创建于2007-09-28

2.4w+

社区成员

C/C++ 工具平台和程序库
申请成为版主
帖子事件
创建了帖子
2004-03-04 08:45
社区公告
暂无公告