有谁知道为什么在:
io.cpp:
# include <iostream>
int ReadNumber()
{
using namespace std;
cout << "Enter a number: ";
int x;
cin >> x;
return x;
}
void WriteAnswer(int x)
{
using namespace std;
cout << "The answer is " << x << endl;
}
主.cpp:
int ReadNumber();
void WriteAnswer(int x);
int main()
{
int x = ReadNumber();
int y = ReadNumber();
WriteAnswer(x+y);
return 0;
}
Readnumber() 中没有 int x;main.cpp 中的前向声明?当我将 int x 放在括号内时,编译器会说:''函数不接受 0 个参数''