functions.cpp

来自「一本语言类编程书籍」· C++ 代码 · 共 37 行

CPP
37
字号
// functions.cpp

//#define TESTFUNCTION              // Uncomment to get trace output

#ifdef TESTFUNCTION
#include <iostream>               // Only required for trace output
#endif

#include "functions.h"

// Definition of the function sum
int fun::sum(int x, int y) {
  #ifdef TESTFUNCTION
  std::cout << "Function sum called." << std::endl;
  #endif

  return x+y;
}

// Definition of the function product
int fun::product(int x, int y) {
  #ifdef TESTFUNCTION
  std::cout << "Function product called." << std::endl;
  #endif

  return x*y;
}

// Definition of the function difference
int fun::difference(int x, int y) {
  #ifdef TESTFUNCTION
  std::cout << "Function difference called." << std::endl;
  #endif

  return x-y;
}

⌨️ 快捷键说明

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