我是一名新的 C++ 学生,我正在尝试为孩子们制作一个基本的程序来学习基础数学。这是一项正在进行的工作,因此某些代码尚未完成。我正在尝试编译到目前为止所做的工作,但收到一条错误消息:47 59 [Error] new declaration 'void add(int, int, std::string, char)' AND 18 5[Error] ambiguates旧声明'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 is a tool for young kids to learn basic math.\n";
cout << "Just press any key and the learning will 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";
}