zl程序教程

您现在的位置是:首页 >  后端

当前栏目

C++ make_pair()用法(三)

C++ 用法 Make pair
2023-09-14 09:09:58 时间

 1.代码示例

#include <iostream>
using namespace std;

int main () {
  pair <string,double> p1 ("zhang",8.8);
  pair <string,double> p2;
  pair <string,double> p3;

  p2.first = "wang";
  p2.second = 1.03;

  p3 = make_pair("li",2.09);
  
  cout << "p1  " << p1.first << " is " << p1.second << endl;
  cout << "p2  " << p2.first << " is " << p2.second << endl;
  cout << "p3  " << p3.first << " is " << p3.second << endl;
  return 0;
}