What's the reason for putting void inside of the params?
Why not just leave it blank?
void createLevel(void); void createLevel();
It means the param of type void* (reference to a void), which is the size of a memory location . You can reference any memory location with this, which in practice anything.
main(void) will be called without any parameters. If we try to pass it then this ends up leading to a compiler error.
When used for a function's parameter list, void specifies that the function takes no parameters. When used in the declaration of a pointer, void specifies that the pointer is "universal." If a pointer's type is void* , the pointer can point to any variable that's not declared with the const or volatile keyword.
Void is used only in method signatures. For return types it means the method will not return anything to the calling code. For parameters it means no parameters are passed to the method.
The void
in the parenthesis are from C. In C a function with empty parentheses could have any number of parameters. In C++ it doesn't make any difference.
void
in function argument lists is a relict of the past (C). In C++, you should leave the parentheses empty. Of course you can keep the void
if it makes you happy.
In C, if you declare a function with empty parentheses, the meaning is that the number of parameters is unknown. void
can be used to make it explicit that no parameters are expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With