-4

This is my complete code:

  #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;
}

This is my error:

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 gives this error when I placed it inside the for loop, it works completely fine if I place it out. Where am I going wrong?

Edit: I amtrying in codechef ide...these are the inputs

3
---
-m-
p--
Barry
  • 286,269
  • 29
  • 621
  • 977
MrRobot9
  • 2,402
  • 4
  • 31
  • 68

1 Answers1

8
#define mp make_pair
...
    int mp = s.find('m');
...
      bar = make_pair(pp,i);

You declared make_pair as a variable, hiding the function.

To fix this, get rid of your horrible macro definition.

  • 1
    yeah but it was giving output when placed outside the for loop, so I was confused. – MrRobot9 Mar 21 '17 at 19:45
  • 1
    @MrRobot9 It's not "outside the for loop" where it works, it's "outside the variable's scope". For instance, inside the loop but before the variable definition, it would also work. –  Mar 21 '17 at 19:52