This doesn't just apply to conversion operators but to all functions in C++ that take no parameters. Personally, I prefer to omit void
for consistency.
The practice originates from C. Originally, when C did not have prototypes, an empty pair of braces was used in function declarations and did not provide any information about the parameters that the function expected.
When prototypes were added, empty braces were retained for function declarations to mean 'unspecified parameters' for flexibility and backwards compatibility. To provide an explicit prototype meaning 'takes no parameters', the syntax (void)
was added.
In C++ all function declarations have to have prototypes, so ()
and (void)
have the same meaning.