我是一名学生,我正在编写我的第一个函数,所以我确信这对我来说显然是错误的。 在第13行,我在参数中遇到错误,告诉我未定义num1和num2。据我了解传递参数,第9行应该告诉第13行num1和num2是什么(1和2)。既然它不起作用,我显然会误会它的工作原理。
如果有人可以解释我在做什么错,我将不胜感激。谢谢你!
#include <iostream>
#include <string>
using namespace std;
int main()
{
Subtract(1,2);
return 0;
}
int Subtract(num1,num2) //num1 and num2 are undefined.
{
int num1;
int num2;
int x;
x = num1 - num2;
cout << x << "/n";
return 0;
}