Why do a Coder in the beginning keep on getting errors like "void value not ignored as it ought to be" in C++?
void value not ignored is an error caused when you try to assign an lvalue the result of a function returning void. Functions that return void do not return anything and can not be used as rvalues, they have no value. Functions that return void are side-effect only operations.
- void myFunc() { /* do thing */ }
- int main()
- {
- int a = myFunc(); // void value not ignored
- return 0;
- }
Comments
Post a Comment