内联函数关键词inline
内联函数的优点:提高执行效率
#pragma region inline.8.1
//程序清单8.1
//inline.cpp – using an inline function
#if 1
#include
inline double square(double x) { return x * x; }
int main()
{
using namespace std;
double a, b;
double c = 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;
}
#endif
#pragma endregion