나는 새로운 C++ 학생이며 기초 수학을 배우는 아이들을위한 기본 프로그램을 만들고자합니다. 이것은 진행중인 작업이므로 일부 코드는 완료되지 않았습니다. 지금까지 한 것을 컴파일하려고하는데 다음과 같은 오류가 발생합니다. 47 59 [오류] 새 선언 'void add (int, int, std :: string, char)'AND 18 5 [Error] ambiguates 오래된 선언 'INT 추가 기능 (INT, INT, 표준 : : 문자열, 문자)'함수의 인자
#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";
}