+ 7
What is difference between void and int
2 Respuestas
+ 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
}
+ 1
Void - null result
Int - integer result