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/

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JerryCheng 的頭像
    JerryCheng

    KwCheng's blog

    JerryCheng 發表在 痞客邦 留言(0) 人氣()