user3781974 user3781974 -4 years ago 90
C++ Question

error: expected primary-expression before 'j'

What is the problem int the code?
I've got:


"error: expected primary-expression before 'j'"


#include <vector>
using namespace std;

void foo(vector<int>& v){
}

int main()
{
foo( vector<int> j);
return 0;
}

Answer Source

This is invalid:

foo( vector<int> j);

because you just can NOT define a named variable in a function call....

you mean for sure

int main()
{
    vector<int> j;
    foo(j);
    return 0;
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download