Ref:http://www.cnblogs.com/berry/articles/1582702.html
(i) inline function (excerpt from the third edition of C + + primer)
Adding the keyword inline to the function declaration or definition in the function return type specifies the min () as inline.
inline int min (int first, int secend) {/****/};
The inline function must be visible to the compiler so that it can expand the function within the point of the call. Unlike a non-inline function, the inline function must be defined in each text file that invokes the function. Of course, for different files of the same program, if the inline function appears, its definition must be the same. For compute of two files. C and DRAW.C program, programmers can not define such a min () function, it is in the compute. C Middle finger one thing while in draw. C Middle finger another thing. If the two definitions are not identical, the program will have undefined behavior:
To ensure that this does not happen, it is recommended that the definition of the inline function be placed in the header file. Include the header file in each file that invokes the inline function. This approach guarantees that there is only one definition for each inline function, and the programmer does not need to copy the code, and it is not possible to cause unintended mismatches during the lifetime of the program.
(ii) The programming style of the inline function (excerpted from the high Quality C++/C Programming Guide)
The keyword inline must be placed with the function definition body in order for the function to be inline, and only the inline is placed before the function declaration .
The following style of function Foo cannot be an inline function:
inline void Foo (int x, int y); Inline is only placed with function declarations
void Foo (int x, int y) {}
The following style of function foo becomes an inline function:
void Foo (int x, int y);
inline void Foo (int x, int y)//inline is placed with function definition body {}
So, inline is a "keyword for implementation", not a "keyword for declaration." In general, the user can read the declaration of a function, but cannot see the definition of the function. Although the inline keyword is prepended to the declaration and definition of inline functions in most textbooks, I don't think inline should appear in the declaration of a function. While this detail does not affect function functionality, it embodies a fundamental tenet of high quality C++/C program design: declarations and definitions are not to be confused, and the user does not need to know whether the function needs to be inline.
C + + inline functions