C++ make_pair()用法

#include 
using namespace std;

int main () {
  pair  p1 ("zhang",8.8);
  pair  p2;
  pair  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;
}

 

你可能感兴趣的:(C++学习)