C++内联函数
其实就是原本调用一个函数的过程,被改编为被调用函数代码嵌入于调用函数代码,来节省调用函数过程中的开销。
#include<iostream> inline double square(double x){return x*x;} int main() { using namespace std; double a,b; double c = 13.0; a = square(5.0); b = square(4.5 + 7.5); cout <<"a="<<a<<",b="<<b<<"\n"; cout <<"c="<<c; cout <<",c squared = "<<square(c++)<<"\n"; cout << "Now c="<< c << "\n"; return 0; }