dimanche 12 mars 2017

invalid initialization of non-const reference of type 'long int&' from a temporary of type 'long int'

The compiler says that a variable is rvalue which would be expected to pass as lvalue in the main function. How can we make v lvalue?

void f(std::vector<std::vector<long>>& vv){
 ...// modify vv
}

int main(){
    std::vector<std::vector<long>> v;
    f(v);
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire