Pair data type not getting passed as argument

i am getting error in passing pair as a argument inside the function

the code is :

#include
#include
bool compare( pair <string,int> a , pair <string,int> b){

  if(a.second==b.second){
      return a.first<b.first;
  }
    return a.second>b.second;

}
using namespace std;
int main() {
int n;
cin>>n;
pair<string,int> emp[n];
for(int i=0;i<n;i++){
int a;
string b;
cin>>a>>b;
emp[i].first=a;
emp[i].second=b;
}
sort(emp,emp+n,compare);
for(int i=0;i<n;i++){
cout<<emp[i].first<<" “<<emp[i].second<<” ";
cout<<endl;
}
return 0;
}

@soorya19k,
Please make sure you share Coding Blocks IDE link of your code, it help us a lot, and will also help you in getting your doubt resolved in lesser time, thanks.

  • Firstly, please use using namespace std;, before any of the function declarations.
  • Secondly, in pairs the order of the data types matter, so for pair<string,int>, the first is string, and second is int, so emp[i].first=b, emp[i].second=a;