C++inline(インラインはいつ使用しますか)
34808 ワード
(1) ?
, 。
(2) ?
, : 。 , , :
#define ABS(x) ((x)>0? (x):-(x))
++i , , : 。
, ? 。
。
(3) inline ?
1、 inline , , ,( ), , 。
2、 , , , , 。 , 。 。
3、 inline , 。
(4) ?
, , 。 , , , , 。 , 。 , , , , , , , , 。
(5) ?
C++ , , 。 , , 。 。
, 。
Class A
{
Private:
int nTest;
Public:
int readtest() { return nTest;}
void settest(int I) { nTest=I; }
}
(6) ?
inline 。
inline int A (int x) { return 2*x; }
, 。
(7) ?
, , , 。 , 。 , , , , 。( , , , ) , 。
(8) ?
VC++, /Ob 。 , #pragma auto_inline 。
(9) :
1. 。
2. 。
。 , , ,
レジスタ( レジスタ ) , 。
, ( )。 び された ,
。 “ ”, 。
“ じゅんかんこうぞう, inline ?”
, , コンパイラ インライン び し 。 inline
int small(int a,int b) { return a < b ? a : b ; } cout << small ( a, b ) << endl ;
cout << (a < b ? a : b) << endl; コンパイラ び し ,
。inline コンパイラ , ,
。 , , ,
。 , インライン 。
, ふくちょう 。