What is the correct way to declare a function with no Input?

So I Want to have a function that gives an output but has no input. Which is the correct code?

1
2
3
double __stdcall GetSomeNumber(){
 return SomeValue;
}


or this

1
2
3
double __stdcall GetSomeNumber(void){
 return SomeValue;
}


Does they keyword "void" need to be used in the function definition if there's no input? Or can I leave the input parameter area of the function definition completely empty?
closed account (N1Co216C)
"void" only needs to be used in the header of your function if your function wont return anything. Since your function has a return statement, you would not use "void". As for a function without an input, your only option I believe is to write a 'cout' statement within the function displaying what your want the function to put out.
Both are correct. void in argumnet list is a C leftover which does exactly nothing in C++
Topic archived. No new replies allowed.