小编Bay*_*ner的帖子

C++通过引用传递不改变参数

我一直盯着这个约一个小时,老实说我不知道​​我错过了什么.

#include <iostream>

using namespace std;

void callChain();

double chain(int, int &, int &);

int main()
{
    callChain();
}

void callChain() {
    int totalInches = 53;
    int feet;
    int inches;

    cout << "\nTesting chain for 53 inches: \nExpected result: 15.46 feet: 4 inches: 5" << endl;
    cout << "Actual result: " << chain(totalInches, feet, inches) << " feet: " << feet << " inches: " << inches << endl;
}

double chain(int totalInches, int &feet, int &inches) {
    feet = …
Run Code Online (Sandbox Code Playgroud)

c++

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

标签 统计

c++ ×1