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

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;
}
...全文
31 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧