+ 1

What are the benefits of using void data types for functions,pointers and more?

31st Jan 2020, 5:39 PM
Harshit Nema
Harshit Nema - avatar
3 Réponses
31st Jan 2020, 5:42 PM
Harshit Nema
Harshit Nema - avatar
+ 2
Void functions don't return a type. They can be used in scenarios when you want to do/change something. But don't want to return anything. Such as: void printOneToTen(){ for(int i = 0; i < 10; i++){ cout << i; } } (C++ Code) In this case I wanted to print the numbers 1 to 10. But didn't want to return anything, so I used a void function.
31st Jan 2020, 5:45 PM
Gevork Bagratyan
+ 1
I'm assuming for functions?
31st Jan 2020, 5:41 PM
Gevork Bagratyan