定义 typedef pair<int,string>p;
定义的p相当于struct
举个栗子:
#include<iostream>
#include<cstdio>
using namespace std;
typedef pair<int,string>p;
struct ac{
int first;
string second;
};
int main()
{
p a;
ac b;
cin>>a.first>>a.second;
cin>>b.first>>b.second;
cout<<"a: "<<a.first<<" "<<a.second<<endl;
cout<<"b: "<<b.first<<" "<<b.second<<endl;
return 0;
}
输入:
1 a.first
2 b.first
输出:
a: 1 a.first
b: 2 b.first