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

📄 ch7.2cube.cc

📁 C++ source code for book-C++ and Object Oriented Numeric computing for scientists and engineers
💻 CC
字号:
#include <iostream> 
#include <complex>

template<class T> T cube(T x) {
  std::cout << " Version 1" << std::endl;
  return x*x*x;
}

template<class T> std::complex<T> cube(std::complex<T> x) {
  std::cout << " Version 2" << std::endl;
  return x*x*x;
}

double cube(double x) {
  std::cout << " Version 3" << std::endl;
  return x*x*x;
}

int main(){

  int i = 2;
  double d =  5;
  std::complex<double> c(- 1, 3);

  cube(i);       // version 1
  cube(d);       // version 3  
  cube(c);       // version 2
} 

⌨️ 快捷键说明

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