Error c2064 when passing an object vector by reference [closed]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-2















I was making coding for fun with vectors, but then I bumped into this error:
Error c2064 'This term doesn't give back a function that accepts 1 arguments';
The error is given in line 33, when I call the function 'ins' passing my vector 'Vett' as an argument, as said in the function declaration.



Code:



struct Num_and_Car {
int n;
char c;
`};`

bool pari (Num_and_Car Acces) {
if (Acces.n % 2 == 0)
return true;
else return false;`
}

void ins (std::vector <Num_and_Car>Vettore) {
int ins;
for (int i = 0; Vettore[i].n != 0; i++) {
std::cin >> ins;
std::cout << "Succesfulln";
if (ins == 0)
break;
else
Vettore.push_back({ ins });
std::cout << "Succesfulln";
}
}

int main () {
int ins = 0;
std::vector <Num_and_Car> Vett;
std::cout <<"Succesfulln";
Vett.push_back({1 });
ins (Vett);
std::cout <<"Succesfulln";

int n = std::count_if(Vett.begin(), Vett.end(), pari);
std::cout << n <<"parin";
std::cin >> n;
}


Thanks in advice for any help.










share|improve this question













closed as off-topic by πάντα ῥεῖ, Peter Ruderman, Gert Arnold, Pearly Spencer, Makyen Nov 23 '18 at 4:02


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – πάντα ῥεῖ, Peter Ruderman, Gert Arnold, Pearly Spencer, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • You declaring an integer called ins may be interfering. It's usually a good idea to make sure names are unique.

    – Carcigenicate
    Nov 22 '18 at 18:05











  • ins (Vett); - what exactly do you expect that to do? ins is a int in that scope.

    – Jesper Juhl
    Nov 22 '18 at 18:06




















-2















I was making coding for fun with vectors, but then I bumped into this error:
Error c2064 'This term doesn't give back a function that accepts 1 arguments';
The error is given in line 33, when I call the function 'ins' passing my vector 'Vett' as an argument, as said in the function declaration.



Code:



struct Num_and_Car {
int n;
char c;
`};`

bool pari (Num_and_Car Acces) {
if (Acces.n % 2 == 0)
return true;
else return false;`
}

void ins (std::vector <Num_and_Car>Vettore) {
int ins;
for (int i = 0; Vettore[i].n != 0; i++) {
std::cin >> ins;
std::cout << "Succesfulln";
if (ins == 0)
break;
else
Vettore.push_back({ ins });
std::cout << "Succesfulln";
}
}

int main () {
int ins = 0;
std::vector <Num_and_Car> Vett;
std::cout <<"Succesfulln";
Vett.push_back({1 });
ins (Vett);
std::cout <<"Succesfulln";

int n = std::count_if(Vett.begin(), Vett.end(), pari);
std::cout << n <<"parin";
std::cin >> n;
}


Thanks in advice for any help.










share|improve this question













closed as off-topic by πάντα ῥεῖ, Peter Ruderman, Gert Arnold, Pearly Spencer, Makyen Nov 23 '18 at 4:02


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – πάντα ῥεῖ, Peter Ruderman, Gert Arnold, Pearly Spencer, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • You declaring an integer called ins may be interfering. It's usually a good idea to make sure names are unique.

    – Carcigenicate
    Nov 22 '18 at 18:05











  • ins (Vett); - what exactly do you expect that to do? ins is a int in that scope.

    – Jesper Juhl
    Nov 22 '18 at 18:06
















-2












-2








-2








I was making coding for fun with vectors, but then I bumped into this error:
Error c2064 'This term doesn't give back a function that accepts 1 arguments';
The error is given in line 33, when I call the function 'ins' passing my vector 'Vett' as an argument, as said in the function declaration.



Code:



struct Num_and_Car {
int n;
char c;
`};`

bool pari (Num_and_Car Acces) {
if (Acces.n % 2 == 0)
return true;
else return false;`
}

void ins (std::vector <Num_and_Car>Vettore) {
int ins;
for (int i = 0; Vettore[i].n != 0; i++) {
std::cin >> ins;
std::cout << "Succesfulln";
if (ins == 0)
break;
else
Vettore.push_back({ ins });
std::cout << "Succesfulln";
}
}

int main () {
int ins = 0;
std::vector <Num_and_Car> Vett;
std::cout <<"Succesfulln";
Vett.push_back({1 });
ins (Vett);
std::cout <<"Succesfulln";

int n = std::count_if(Vett.begin(), Vett.end(), pari);
std::cout << n <<"parin";
std::cin >> n;
}


Thanks in advice for any help.










share|improve this question














I was making coding for fun with vectors, but then I bumped into this error:
Error c2064 'This term doesn't give back a function that accepts 1 arguments';
The error is given in line 33, when I call the function 'ins' passing my vector 'Vett' as an argument, as said in the function declaration.



Code:



struct Num_and_Car {
int n;
char c;
`};`

bool pari (Num_and_Car Acces) {
if (Acces.n % 2 == 0)
return true;
else return false;`
}

void ins (std::vector <Num_and_Car>Vettore) {
int ins;
for (int i = 0; Vettore[i].n != 0; i++) {
std::cin >> ins;
std::cout << "Succesfulln";
if (ins == 0)
break;
else
Vettore.push_back({ ins });
std::cout << "Succesfulln";
}
}

int main () {
int ins = 0;
std::vector <Num_and_Car> Vett;
std::cout <<"Succesfulln";
Vett.push_back({1 });
ins (Vett);
std::cout <<"Succesfulln";

int n = std::count_if(Vett.begin(), Vett.end(), pari);
std::cout << n <<"parin";
std::cin >> n;
}


Thanks in advice for any help.







c++ function vector arguments






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 18:03









A.LuginiA.Lugini

102




102




closed as off-topic by πάντα ῥεῖ, Peter Ruderman, Gert Arnold, Pearly Spencer, Makyen Nov 23 '18 at 4:02


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – πάντα ῥεῖ, Peter Ruderman, Gert Arnold, Pearly Spencer, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by πάντα ῥεῖ, Peter Ruderman, Gert Arnold, Pearly Spencer, Makyen Nov 23 '18 at 4:02


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – πάντα ῥεῖ, Peter Ruderman, Gert Arnold, Pearly Spencer, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.













  • You declaring an integer called ins may be interfering. It's usually a good idea to make sure names are unique.

    – Carcigenicate
    Nov 22 '18 at 18:05











  • ins (Vett); - what exactly do you expect that to do? ins is a int in that scope.

    – Jesper Juhl
    Nov 22 '18 at 18:06





















  • You declaring an integer called ins may be interfering. It's usually a good idea to make sure names are unique.

    – Carcigenicate
    Nov 22 '18 at 18:05











  • ins (Vett); - what exactly do you expect that to do? ins is a int in that scope.

    – Jesper Juhl
    Nov 22 '18 at 18:06



















You declaring an integer called ins may be interfering. It's usually a good idea to make sure names are unique.

– Carcigenicate
Nov 22 '18 at 18:05





You declaring an integer called ins may be interfering. It's usually a good idea to make sure names are unique.

– Carcigenicate
Nov 22 '18 at 18:05













ins (Vett); - what exactly do you expect that to do? ins is a int in that scope.

– Jesper Juhl
Nov 22 '18 at 18:06







ins (Vett); - what exactly do you expect that to do? ins is a int in that scope.

– Jesper Juhl
Nov 22 '18 at 18:06














1 Answer
1






active

oldest

votes


















1














In main, you are using "ins" both as a variable name and a function name. The variable hides the function, and then you are trying to use the variable as if it is the function - that is not valid.



Rename the local variable in main and also remove character grave (`) wherever it is placed then the code will work perfectly.






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    In main, you are using "ins" both as a variable name and a function name. The variable hides the function, and then you are trying to use the variable as if it is the function - that is not valid.



    Rename the local variable in main and also remove character grave (`) wherever it is placed then the code will work perfectly.






    share|improve this answer




























      1














      In main, you are using "ins" both as a variable name and a function name. The variable hides the function, and then you are trying to use the variable as if it is the function - that is not valid.



      Rename the local variable in main and also remove character grave (`) wherever it is placed then the code will work perfectly.






      share|improve this answer


























        1












        1








        1







        In main, you are using "ins" both as a variable name and a function name. The variable hides the function, and then you are trying to use the variable as if it is the function - that is not valid.



        Rename the local variable in main and also remove character grave (`) wherever it is placed then the code will work perfectly.






        share|improve this answer













        In main, you are using "ins" both as a variable name and a function name. The variable hides the function, and then you are trying to use the variable as if it is the function - that is not valid.



        Rename the local variable in main and also remove character grave (`) wherever it is placed then the code will work perfectly.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 18:31









        007007

        112




        112

















            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?