+ 1

When we use void ,and when we use return in function in c ++

please help me

12th Jan 2017, 6:43 PM
Nadeem Qasimy
Nadeem Qasimy - avatar
2 Answers
+ 6
You use void when your functions doesnt return anything. Aka your functions does not give out any value back to your system. For example, if your functions just does writing stuff on the console, then you do not need to return a value, hence you use void. You use return if you want the function to give the system a value. For example, if you want the function to add 2 values and give back the value, that is where you use return.(And int as the return-type)
12th Jan 2017, 7:26 PM
Wen Qin
Wen Qin - avatar
+ 3
when our function does not need to return a value we use void. for example we can write a function to send data to a server and of course the function does not send anything in response.
12th Jan 2017, 7:18 PM
mojtaba noghabaee
mojtaba noghabaee - avatar