+ 1
Calculating Sums in C++
I am not quite grasping calling voids in C++ and could use some help (without the “voids” in the example, the solution is correct): #include <iostream> #include <string> using namespace std; //complete the function void int add(int x, int y) { return x+y; } //overload it to sum doubles void double add(double x, double y) { return x+y; } int main() { //calling cout<<add(5,6)<<endl; cout<<add(1.2, 6.5); return 0; }
2 Respuestas
+ 3
Void means it will return nothing.
You can't name a function "void int" or "void double". A function in C++ must have only one return type.
+ 1
How could it be void and int in the same time ?!!
You must declare the function either void or int/ double/ float .... Etc