私は新しいC ++の学生で、子供たちが基本的な数学を学ぶための基本的なプログラムを作成しようとしています. これは進行中の作業であるため、一部のコードは完了していません。これまでに行ったことをコンパイルしようとしていますが、次のようなエラーが表示されます: 47 59 [エラー] 新しい宣言 '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";
}