/*
*函数特点:易于维护,慢;表达式特点:不易维护,快。
*内联函数:以函数的形式出现在代码中(易于维护);编译阶段在调入点被展开,从而消除了函数调用的消耗(快)。
*/
#include <iostream>
using namespace std;
*函数特点:易于维护,慢;表达式特点:不易维护,快。
*内联函数:以函数的形式出现在代码中(易于维护);编译阶段在调入点被展开,从而消除了函数调用的消耗(快)。
*/
#include <iostream>
using namespace std;
inline int max(int i, int j);
int main(int argc, char **argv)
{
int ia = 0, ib = 0;
{
int ia = 0, ib = 0;
cout << "input two integers: " << endl;
cin >> ia >> ib;
cin >> ia >> ib;
cout << "max == " << max(ia, ib) << endl; // max(a, b)在编译阶段被展开为表达式 i > j ? i : j
system("pause");
return 0;
}
return 0;
}
inline int max(int i, int j)
{
return (i > j ? i : j);
}
{
return (i > j ? i : j);
}
转载于:https://blog.51cto.com/programs/235799