这是我的代码:
#include <iostream>
#include "rlutil.h"
#include <cmath>
#include <string>
using namespace std;
int getNumber()
{
int firstNumber;
int secondNumber;
cout << "Please Enter Your First Number." << endl;
cin >> firstNumber;
cout << "Please Enter Your Second Number." << endl;
cin >> secondNumber;
return 0;
}
int writeNumber()
{
getNumber();
rlutil::setColor(3);
cout << firstNumber + secondNumber << endl;
return 0;
}
当我编译它以检查错误时,它给了我:
/home/bresser/Documents/LearnC++/main.cpp||在函数'int writeNumber()'中:| /home/bresser/Documents/LearnC++/main.cpp|24|错误:“firstNumber”未在此范围内声明| /home/bresser/Documents/LearnC++/main.cpp|24|错误:“secondNumber”未在此范围内声明| ||=== 构建完成:2 个错误,0 个警告 ===|
我有点明白它在说什么,只是不明白如何解决它。