Problem with a function

Hi everybody! I try to create same little function with 2d vector as argument to it, but my compiler gives ununderstandable error for me. Can somebody help?

My compiler gives me a mistake in line 20, it says:
error: expected ',' or '...' before '(' token

Here is a code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <vector>

#define ROW 8
#define COL 8

using namespace std;

void fillVect(vector<vector<int> >&);

int main()
{
    vector<vector<int> > myVec(ROW,vector<int>(COL));

    //some code

    return 0;
}

void fillVect(vector<vector<int> > &vect(ROW,vector<int>(COL)))
{
    //some code
}
Line 20 should be:void fillVect(vector<vector<int> > &vect)
As I understand I shouldn't declare all sizes of vector. The compiler does it by itself. Thanks to this operator &. Am I right?
Your line was just syntaxically incorrect. Argument should contain: variable type (vector<vector<int>>& in your case) and local variable name (vect in your case)
It may be a misunderstanding of the meaning of line 13, which led to confusion later on.

We can declare a vector like this:
vector<int> a;

and a 2-D vector like this:
vector<vector<int> > b;

What line 13 is doing is calling the constructor to build the new vector. That's not part of the declaration, and it doesn't make sense to put the constructor in the function definition.
http://www.cplusplus.com/reference/vector/vector/vector/
Thanks guys for all. I understood.
Topic archived. No new replies allowed.