Error - No matching function for call to 'MyFunction'

Hello,

I am wondering why my compiler is not recognizing a function (that appears to be correctly formatted) in my main function. The error I am receiving is indicated in the comments. I have tried putting the contents of the MakeQuestion function into my main program (i.e. not using the function MakeFunction at all), and it has worked, so I'm not sure what's wrong.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

void MakeQuestion(int n, int& a, int& b, int& atimesb); // function prototype for creating a question to ask the user

int NewRandomNumber (int n); // function prototype for generating random numbers

int main()
{
int n; // declares integer variable n

// do some stuff, including getting n from the user

srand(time(NULL)); // set seed for random number generation

// call to function NewQuestion - error occurs here: No matching function for call to 'MakeQuestion'
MakeQuestion(n);

// program to continue on below...

return 0;
}

// function definition for generating new questions
void MakeQuestion(int n, int& a, int& b, int& atimesb) /* inout */
{
// generate the first random number
a = NewRandomNumber(n);
// generate the second random number
b = NewRandomNumber(n);
    
// generate the answer of the two random numbers
atimesb = a * b;
}

// function NewRandomNumber follows; working correctly...
1
2
3
4
5
// call to function NewQuestion - error occurs here: No matching function for call to 'MakeQuestion'
int a = 0 ;
int b = 0 ;
int atimesb = 0 ;
MakeQuestion( n, a, b, atimesb ) ;
Thank you, I can't believe I forgot something that was seemingly so simple!
Topic archived. No new replies allowed.