For example, if I made the variable:
void helloWorld;
What could I do with it? Since it represents nothing, at first I thought that nothing could be done with it. I am aware that functions use void for no return value, but do the variables have a purpose?
-- EDIT --
I have found out the answer. I am now aware that void variables are illegal in programming languages such as Java, C++ and C. Thanks for all of your answers!
The void data type is typically used in the definition and prototyping of functions to indicate that either nothing is being passed in and/or nothing is being returned.
We say that a variable is void if its symbol has an unassigned value cell (see Symbol Components). Under Emacs Lisp's default dynamic scoping rule (see Scoping Rules for Variable Bindings), the value cell stores the variable's current (local or global) value.
The void type, in several programming languages derived from C and Algol68, is the return type of a function that returns normally, but does not provide a result value to its caller. Usually such functions are called for their side effects, such as performing some task or writing to their output parameters.
void
variables are invalid in C/C++ because the compiler can not determine their size. void
is only valid as function argument list (takes no arguments) or return types (returns nothing).
There is void *
which just means "any type pointer" and is a generic pointer type, but you are not allowed to dereference it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With