error : syntax error: missing ')' before 'const'

Feb 18, 2010 at 4:23pm
I have a function prototype

void AdjustDL (const vector<vector<int>>& adjMat);

and calls this function from the main function

1
2
3
4
5
while( *min_pos != 0 ){
	DomSet.push_back( ChooseVertex(DL) );
	AdjustDL(const vector<vector<int>>& adjMat);
	
}


But i got three errors at line 3
1> : error C2143: syntax error : missing ')' before 'const'


error c2660: 'AdjustDL' : function does not take 0 arguments


error C2059: syntax error : ')'


I cannot find any problem. Any help would be appreciated. :)
Last edited on Feb 18, 2010 at 4:23pm
Feb 18, 2010 at 4:35pm
You are calling the function, so don't just repeat the parameter list. You actually have to pass a const vector<vector<int>> reference.
Feb 18, 2010 at 5:46pm
The object you pass doesn't need to be const, but you are (supposed to be) guaranteed that the AdjustDL() function will not modify it.

Unless you are using C++0x, you are going to have trouble with the ">>" in your templates. (And just because your compiler is smart enough to handle it doesn't mean anything...)

Make sure you put a space between them. My personal preference is to put a space before every template < and after every template >, like this:
void AdjustDL( const vector <vector <int> > & );

Hope this helps.
Feb 18, 2010 at 8:42pm
When you call the funciton, you don't give the type.

1
2
3
4
5
6
7
8
9
10
11
12
13
// this is a prototype
void AdjustDL (const vector<vector<int>>& adjMat);
//                   ^
//                   |
//                  Specify the type


// this is how you call the function:

AdjustDL( adjMat );
//        ^
//        |
//        don't specify the type 
Topic archived. No new replies allowed.