Oct 11, 2011 at 6:00pm UTC
Hello.
I have an urgent problem. I wrote a procedure but it doesn't work.
I can't find the problem. :(
So please help me.
The code is posted below:
1 2 3 4 5 6 7 8
void kiszomszedsagiLista(vector<pair<int , int > >& eL, int & nrPontok, vector<pair<int , vector<int > > >& kiSzL) {
kiSzL.resize(nrPontok+1);
for (int i=1; i<eL.size(); ++i) {
kiSzL[eL[i].first] = make_pair( ++(kiSzL[eL[i].first].first),
kiSzL[eL[i].first].second.push_back(eL[i].second)); // line 82
}
return ;
}
And the error message:
main.cpp:82: error: invalid use of void expression
Important! nrPontok >= eL.size()
Thanks for trying.
Last edited on Oct 11, 2011 at 6:04pm UTC
Oct 11, 2011 at 6:17pm UTC
void kiszomszedsagiLista(vector<pair<int, int> >& eL, int& nrPontok, vector<pair<int, vector<int> > >& kiSzL) {
kiSzL.resize(nrPontok+1);
for (int i=1; i<eL.size(); ++i) {
kiSzL[eL[i].first] = make_pair( ++(kiSzL[eL[i].first].first),
kiSzL[eL[i].first].second.push_back(eL[i].second)); // line 82
}
return;
}
in your line 82, type of output of kiSzL[eL[i].first].second.push_back(eL[i].second)) will be output of function push_back .... which is void. but make_pair will not accept second argument as void..
Oct 11, 2011 at 6:21pm UTC
void vector<T>::push_back(const T&);
You are trying to create a pair int-void
Modularize a little more. And don't count lines of code.
Oct 11, 2011 at 6:26pm UTC
Hi BHUPENDER KUMAR.
Thanks for fast answer.
I think I am now understand what is the problem.
I will post the solution in several minutes.