小编Kyl*_*e A的帖子

使用void函数设置main函数中变量的值

为什么num1价值等于0?我不明白.怎么会传递num1getScore功能,并使用cin不改变价值?如何更改基于什么是它的价值cinscore.

#include <iostream>
using namespace std;

void getScore(double);

int main(int argc, const char * argv[]) {
    double num1;
    getScore(num1);
    cout << "NUM 1 got set to " << num1 << endl;
    return 0;
}

void getScore(double score) {
    cout << "whats the score";
    cin >> score;
    cout << "num is " << score << endl;
}
Run Code Online (Sandbox Code Playgroud)

c++

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

标签 统计

c++ ×1