void

In some cases, you need to indicate that a function does not have parameters or will not return a value; in both cases, you can use the keyword void:

    void print_message(void)     {         cout << "no inputs, no return value" << endl;     }

The use of void in the parameter list is optional; an empty pair of parentheses is acceptable and is preferable. This is the only way to indicate that a function returns no value other than returning void.

Note that void is not really a type because you cannot create a void variable; it is the absence of a type. As you'll find out in the next chapter, you can create pointers of the type void, but you will not be able to use the memory that such pointers point to without casting to a typed pointer: to use the ...

Get Beginning C++ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.