ex0517.cpp

来自「practice c++, it is from the book http:/」· C++ 代码 · 共 27 行

CPP
27
字号
//  Programming with C++, Second Edition, by John R. Hubbard
//  Copyright McGraw-Hill, 2000
//  Example 5.17 on page 104
//  Passing By Value and Passing By Reference

#include <iostream>  // defines the cout object
using namespace std;

void f(int,int&);
// changes reference argument to 99:;

int main()
{ // tests the f() function:
  int a = 22, b = 44;
  cout << "a = " << a << ", b = " << b << endl;
  f(a,b);
  cout << "a = " << a << ", b = " << b << endl;
  f(2*a-3,b);
  cout << "a = " << a << ", b = " << b << endl;
}

void f(int x, int& y)
{ // changes reference argument to 99:
  x = 88;
  y = 99;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?