+ 1

can any one define void in a short way..?

void is a bassic data type that defines a valuless stats.... what dose it mean by valueless cany any one explain it in short way... Regards.

27th Sep 2016, 1:39 PM
zbwafi
7 Respuestas
+ 4
A void function shows that there is no return.
2nd Apr 2017, 12:29 PM
Yusuf Said
Yusuf Said - avatar
+ 3
void means return nothing and just do what I want
27th Sep 2016, 9:09 PM
Ayin GhaziMoradi
+ 2
Basically it means "nothing" or "no type" Function return value: void myFunc(int) -- the function returns nothing
27th Sep 2016, 2:15 PM
Raphael
Raphael - avatar
+ 2
void setAttr(int n) //returns nothing int getAttr(void) //takes no parameter
27th Sep 2016, 3:05 PM
Zen
Zen - avatar
+ 2
srry..IDK
7th Oct 2016, 2:03 PM
nithish
+ 1
EDIT: Sorry, I just realized you wanted a short explanation. This is not exactly short, but I hope it helps. void is used when a function returns nothing. for example: void myFunc() { cout << "Hello" << endl; } When called, myFunc() doesn't return anything, it just prints something to the screen ("Hello"). int is used when a function returns an integer. ie: int myOtherFunc() { return 42; } When called, myOtherFunc() returns 42. You can use the return value, for example: - assign it to a variable: int number = MyOtherFunc(); // here number will be equal to 42 - or you can do operations on it: int sum = myOtherFunc() + 10; // here sum will be equal to 52 You couldn't do that with a void function. The same works with other data types, you can have a function that returns a boolean, in this case the function will be something like bool func(){return true;}. Etc. The functions I used as exemples have no parameters, but it also works otherwise. Just keep in mind that the data type of the function is not related to the data types of the parameters, you can make a function that returns nothing but takes an integer, ex: void func(int number);, or a function that returns an integer but takes two floats, ex: int func(float number, float number2);. This is a very basic explanation but I hope it helps.
15th Nov 2016, 6:58 AM
koshe
koshe - avatar
+ 1
thank you #koshe
15th Nov 2016, 11:00 AM
zbwafi