【发布时间】:2021-05-27 09:34:08
【问题描述】:
int calculateX()
{
int x;
cout<<"Enter value for x: ";
cin>>x;
return x;
}
int anotherFunction()
{
/////
}
int main()
{
calculateX();
anotherFunction();
return 0;
}
这是一个代码示例。我如何才能将用户在 calculateX() 函数中的输入用于函数 anotherFunction() ?
【问题讨论】:
-
int anotherFunction(int)? (和anotherFunction(calculateX());用法或类似) -
只需添加一个
int参数并使用anotherFunction(calculateX());调用它calculateX的返回值存在那里是有原因的。
标签: c++