C++ void Keyword
Example
Create a function that does not return a value:
void myFunction() {
cout << "I just got executed!";
}
int main() {
myFunction();
return 0;
}
Definition and Usage
The void keyword specifies that a function does not return a value. Write it in front of the function name, where the return type would be.
It also has a second use: a void* pointer can point to data of any type. You must convert it to the right pointer type before you can use the value.
Related Pages
Read more about functions in our C++ Functions Tutorial.
Read more about return values in our C++ Return Values Tutorial.