Declaring Functions That Take No Arguments

A function declared with the single keyword void in the argument declaration list takes no arguments, as long as the keyword void is the first and only member of the argument declaration list. Arguments of type void elsewhere in the list produce errors. For example:

long GetTickCount( void );            // OK
long GetTickCount( int Reset, void ); // Error
long GetTickCount( void, int Reset ); // Error

In C++, explicitly specifying that a function requires no arguments is the same as declaring a function with an empty argument declaration list. Therefore, the following two statements are identical:

long GetTickCount();
long GetTickCount( void );

Note that, while it is illegal to specify a void argument except as outlined here, types derived from type void (such as pointers to void and arrays of void) can appear anywhere the argument declaration list.

See Also

Reference

Function Declarations