close
Code written in-place is significantly faster , so C++ offers a way to combine the advantages of functions
with the speed of code written in-place: inline functions.
for example :
inline
int
min(
int
nX,
int
nY)
{
return
nX > nY ? nY : nX;
}
int
main()
{
using
namespace
std;
cout << (5 > 6 ? 6 : 5) << endl;
cout << (3 > 2 ? 2 : 3) << endl;
return
0;
}
ref : http://www.learncpp.com/cpp-tutorial/75-inline-functions/
全站熱搜