c++ – Function declaration without parameters

Question:

How do I correctly declare a function without parameters in C ++?

void func(void);

or

void func();

Answer:

In C++ declaring a function with no arguments does not require the explicit spelling of the word void . Code using void allowed for C compatibility reasons, but should be avoided in C++ .

Scroll to Top