I am getting the problem on line 15 and 20 where i am trying to pushback elements in to the pair vector
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int main()
{
int x, y, a, b, c, d, j, m, v;
vector<pair<int, int> > ladder;
cin >> x >> y;
for (int i = 0; i < x; i++) {
cin >> a >> b;
ladder.push_back(pair(a, b));
}
vector<pair<int, int> > snake;
for (int i = 0; i < y; i++) {
cin >> c >> d;
snake.push_back(pair(c, d));
}
vector<int> moves;
cin >> v;
while (v != 0) {
moves.push_back(v);
v = 0;
cin >> v;
}
return 0;
}
My errors are:
prog.cpp: In function ‘int main()’:
prog.cpp:15:30: error: missing template arguments before ‘(’ token
ladder.push_back(pair(a, b));
^
prog.cpp:20:29: error: missing template arguments before ‘(’ token
snake.push_back(pair(c, d));
I have the code here to test: https://ideone.com/ZPKP4s
Your issue is on these two lines:
ladder.push_back(pair(a, b));
ladder.push_back(pair(c, d));
You need to specify what types of pairs these are:
ladder.push_back(pair<int, int>(a, b));
ladder.push_back(pair<int, int>(c, d));