C++ 臨時測驗
Define:
* U7 j; U$ j. \
) v" H9 T/ \+ l9 I2 u7 c# hconst int x = 17;
' o, `- U" k- cclass A$ e5 f$ T- |# G( O6 K3 ` n
{9 l! v$ D6 D9 R
public:
; E4 m1 Y1 w0 P8 b3 {8 p0 X A();
6 R ^$ J# T. ^ A(int n);
: I" I Y& I) ` v& x int f() const;& c B+ Z1 G- r' J% l3 h+ q
int g(const A& x);
; K6 w0 i$ @- X1 \( sprivate:% T; ^3 @0 Z% c
int i;0 A% @) N, H3 h5 F
};
' N& e: J ?; i2 ?$ I+ ]- _
& Y2 k0 e8 f1 I6 I
0 A- w$ Q s Z+ O問:9 ?/ |& A- R: R" W2 g* X" P9 q
Each of the three const keywords is a promise to the compiler that the compiler will enforce.
, v3 z A c& k2 r" |What is the promise in each case?