Any advice to avoid this error?

I'm getting an error: "variable or field 'biggestNumb' declared void." I have a task to tell the console 3 integers and it has to sort out the greatest one. I'm a very beginner to the C++ so you may find this code a bit messy. Anyway, here it is:




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
#include <iostream>
#include <Windows.h>
using namespace std;
int number1, number2, number3;
void biggestNumb(number1, number2, number3)
{
    if(number1>number2&&number1>number3)
    {
        cout << endl;
        cout << number1;
    }
    else if(number2>number1&&number2>number3)
    {
        cout << endl;
        cout << number2;
    }
    else if(number3>number1&&number3>number2)
    {
        cout << endl;
        cout << number3;
    }
}

int main()
{

    cin >> number1;
    cin >> number2;
    cin >> number3;
    biggestNumb(number1, number2, number3);
}
Last edited on
Please read http://www.cplusplus.com/doc/tutorial/functions/ to understand proper function syntax.

Remove line 4, and make line 5 be
1
2
3
4
void biggestNumb(int number1, int number2, int number3)
{
    // ...
}


Move your line 4 into the beginning of main.
1
2
3
4
5
6
7
8
int main()
{
    int number1, number2, number3;
    cin >> number1;
    cin >> number2;
    cin >> number3;
    biggestNumb(number1, number2, number3);
}

PS: Don't include <windows.h> unless you are using Windows-specific functions.

Thanks, that worked out :) Yeah earlier I used the Sleep() function and removed it and forgot to remove Windows.h Thanks for your help
What is the proper result, if input is
5 2 5
Topic archived. No new replies allowed.