小编Zak*_*aku的帖子

为什么这里不使用函数参数?

我正在阅读本教程: https://www.learncpp.com/cpp-tutorial/how-to-design-your-first-programs/ 我注意到作者没有在此函数中使用参数:

int getUserInput()
{
    std::cout << "Enter an integer ";
    int input{};
    std::cin >> input;

    return input;
}
Run Code Online (Sandbox Code Playgroud)

做这样的事情可以吗?

int getUserInput(int input)
{
    std::cout << "Enter an integer ";
    std::cin >> input;

    return input;
}
Run Code Online (Sandbox Code Playgroud)

c++ parameters arguments

0
推荐指数
1
解决办法
64
查看次数

标签 统计

arguments ×1

c++ ×1

parameters ×1