+ 7

What is difference between void and int

26th Jun 2019, 9:36 AM
Muaz Ahmad
Muaz Ahmad - avatar
2 Answers
+ 5
As a return type? void means that the function doesn't return anything. int means that the function returns an integer: int add(int a, int b) { return a + b; // <<== return value of the function is an integer } void say_hello(string name) { cout << "Hello " << name; // <<== this function doesn't return any value, its return type is void }
26th Jun 2019, 9:54 AM
Anna
Anna - avatar
+ 1
Void - null result Int - integer result
7th Jul 2019, 9:11 PM
Nikita NyaRu
Nikita NyaRu - avatar