Template parameters

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
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..
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.
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.
I am ready.


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].first);
        kiSzL[eL[i].first].second.push_back(eL[i].second);
    }
    return;
}



I rethought the problem. Thank you BHUPENDER KUMAR.
Topic archived. No new replies allowed.