multiple parameters with vectors

C

cdg

Is there any reason why code passing multiple parameters with a vector
is not legal.
I have left out most of the unneccessary details to try and make the
problem clearer. Earlier in the program the vector is passed without any
problems, but it was the only parameter.

#include <iostream>
#include <vector>
using namespace std;

void CompareValues(vector<int>& cards,int,int); //prototype

void main()
{

}

void AnotherFunction()
{
CompareValues(vector<int>& any_vector, result, ct); //function call
//*** I am getting an error message here, saying
// "illegal use of this type as an expression"
}

void CompareValues(vector<int>& any_vector, int result, int ct)
{

}
 
C

cdg

This is the correct code to show the problem. There were different vector
names in the previously posted code that I had changed just to post the
problem with multiple parameters.

#include <iostream>
#include <vector>
using namespace std;

void CompareValues(vector<int>& any_vector,int,int); //prototype

void main()
{

}

void AnotherFunction()
{
CompareValues(vector<int>& any_vector, result, ct); //function call
//*** I am getting an error message here, saying
// "illegal use of this type as an expression"

}

void CompareValues(vector<int>& any_vector, int result, int ct)
{

}
 
C

cdg

I tried it and it did work. And I actually had written it correctly
earlier in the program, but I didn't notice it this time.
 
J

john

cdg a écrit :
Is there any reason why code passing multiple parameters with a vector
is not legal.
I have left out most of the unneccessary details to try and make the
problem clearer. Earlier in the program the vector is passed without any
problems, but it was the only parameter.

#include <iostream>
#include <vector>
using namespace std;

void CompareValues(vector<int>& cards,int,int); //prototype

void main()
{

}

void AnotherFunction()
{
CompareValues(vector<int>& any_vector, result, ct); //function call

Try

CompareValues(any_vector, result, cnt);

Do not put the argument type in the function call.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top