I am receiving the following error while calling push_back() method on the Vector class object:
error: request for member 'push_back' in 'edges.std::vector<_Tp, _Alloc>::operator[]<int, std::allocator<int> >(((std::vector<int>::size_type)a))', which is of non-class type 'int'
I am trying to create a graph using an adjacency list and it isn't working
#include <bits/stdc++.h>
using namespace std;
/****************************************/
/// INPUT / OUTPUT
ifstream f("ciclueuler.in");
ofstream g("ciclueuler.out");
/****************************************/
/// GLOBAL DECLARATIONS
int n, m;
const int nmax = 100005;
vector <int> edges;
/****************************************/
inline void readInput()
{
f >> n >> m;
for(int i = 1 ; i <= m ; ++ i)
{
int a, b;
f >> a >> b;
edges[a].push_back(b);
}
}
int main()
{
readInput();
return 0;
}
Sorry for the bad writing this is my first question!
edges[a].push_back(b);to do.