'make_pair' 不能作为函数使用
'make_pair' cannot be used as a function
这是我的完整代码:
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define mp make_pair
#define ss second
int main(void) {
int m;
vector <string> grid;
cin >> m;
pair <int,int> foo;
pair <int,int> bar;
// bar =make_pair (10.5,'A');
foo = make_pair (1,2);
cout<<foo.ss<<endl;
for(int i=0; i<m; i++) {
string s; cin >> s;
grid.push_back(s);
int pp = s.find('p');
int mp = s.find('m');
if(pp>=0){
bar = make_pair(pp,i);
}
cout<<pp<<endl;
}
return 0;
}
这是我的错误:
prog.cpp: In function 'int main()':
prog.cpp:40:32: error: 'make_pair' cannot be used as a function
bar = make_pair(pp,i);
^
make_pair
当我把它放在 ide for 循环中时给出了这个错误,如果我把它放在外面它完全可以正常工作。我哪里错了?
编辑:我正在尝试使用 codechef ide...这些是输入
3
---
-m-
p--
#define mp make_pair
...
int mp = s.find('m');
...
bar = make_pair(pp,i);
您将 make_pair
声明为变量,隐藏了函数。
要解决此问题,请删除您糟糕的宏定义。
这是我的完整代码:
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define mp make_pair
#define ss second
int main(void) {
int m;
vector <string> grid;
cin >> m;
pair <int,int> foo;
pair <int,int> bar;
// bar =make_pair (10.5,'A');
foo = make_pair (1,2);
cout<<foo.ss<<endl;
for(int i=0; i<m; i++) {
string s; cin >> s;
grid.push_back(s);
int pp = s.find('p');
int mp = s.find('m');
if(pp>=0){
bar = make_pair(pp,i);
}
cout<<pp<<endl;
}
return 0;
}
这是我的错误:
prog.cpp: In function 'int main()':
prog.cpp:40:32: error: 'make_pair' cannot be used as a function
bar = make_pair(pp,i);
^
make_pair
当我把它放在 ide for 循环中时给出了这个错误,如果我把它放在外面它完全可以正常工作。我哪里错了?
编辑:我正在尝试使用 codechef ide...这些是输入
3
---
-m-
p--
#define mp make_pair ... int mp = s.find('m'); ... bar = make_pair(pp,i);
您将 make_pair
声明为变量,隐藏了函数。
要解决此问题,请删除您糟糕的宏定义。