I looked at several past questions (e.g. no instance of overloaded function) but these were not relevant. I understand that there is a type mismatch but I don't understand why, with my setup, I'm getting this error.
I'm getting this error:
no instance of overloaded function "std::vector<_Tp, _Alloc>::push_back [with _Tp=int, _Alloc=std::allocator<int>]" matches the argument list and object (the object has type qualifiers that prevent a match) -- argument types are: (int) -- object type is: const std::vector<int, std::allocator<int>>
This is the code:
std::vector<int> sorted_edges;
...
//let's sort the edges
for(int i = 0; i < num_nodes; ++i){
for(int j = 0; j < num_nodes; ++j){
if(graph[i][j] != INF){
sorted_edges.push_back(i);
}
}
}
Note: I'm not going to push an int
into sorted_edges
- I was testing to see whether I was incorrectly creating my edge struct or whether I was using vectors incorrectly.