⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prog8_04.cpp

📁 一本语言类编程书籍
💻 CPP
字号:
// Program 8.4 Modifying the original value of a function argument
#include <iostream>
using std::cout;
using std::endl;

double change_it(double* pointer_to_it);  // Function prototype

int main() {
  double it = 5.0;
  double result = change_it(&it);         // Now we pass the address

  cout << "After function execution, it = " << it     << endl
       << "Result returned is "             << result << endl;

  return 0;
}

// Function to modify an argument and return it
double change_it(double* pit) {
  *pit += 10.0;                          // This modifies the original it
  cout << endl
       << "Within function, *pit = " << *pit << endl;
  return *pit;
}

⌨️ 快捷键说明

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