c++ - Arguments in function -
i new c++ student , trying make basic program kids learn basic math. work in progress of code not done. trying compile have done far , getting error says: 47 59 [error] new declaration 'void add(int, int, std::string, char)' , 18 5[error] ambiguates old declaration 'int add(int, int, std::string, char)'
#include <iostream> #include <iomanip> #include <time.h> #include <string> #include <cstdlib> #define over2 "\t\t" #define over3 "\t\t\t" #define over4 "\t\t\t\t" #define down5 "\n\n\n\n\n" #define down8 "\n\n\n\n\n\n\n\n" #define down10 "\n\n\n\n\n\n\n\n\n\n" #define down12 "\n\n\n\n\n\n\n\n\n\n\n\n" using namespace std; int add(int,int,string,char); int sub(); int multi(); int div(); int main(int argc, char** argv) { int num1, num2; unsigned seed = time(0); srand(seed); num1 = 1 +rand() % 4; num2 = 1 +rand() % 4; // correctanswer = (num1+num2); cout << "this program tool young kids learn basic math.\n"; cout << "just press key , learning commence!\n"; system("cls"); add(num1, num2, "addition", '+'); // addresults(num1+num2); return 0; } void add(int num1, int num2, string operation, char symbol) { cout << down8; cout << over3 << operation << endl; cout << over3 << "________\n"; cout << over3 << setw(3) << num1 << endl; cout << over3 << symbol << endl; cout << over3 << setw(3) << num2 << endl; cout << over3 << "________\n"; }
the return types of add
method differ in declaration (int
) , in definition (void
). think definition's type should changed int
, make return result.
Comments
Post a Comment