C++语言: Codee#25734
01 /*
02 枚举值不占用对象空间,编译期间得到枚举值
03 */
04
05 #include <iostream>
06 using namespace std;
07
08 class Bunch
09 {
10 enum
11 {
12 size = 1000
13 };
14 int i[size];
15 };
16
17 int main()
18 {
19 cout << "sizeof(bunch) =" << sizeof(Bunch)
20 << ",sizeof(i[1000]) = "
21 << sizeof(int[1000]) << endl;
22 return 0;
23 }
24
25 /*
26 Output:
27 sizeof(bunch) =4000,sizeof(i[1000]) = 4000
28 */
02 枚举值不占用对象空间,编译期间得到枚举值
03 */
04
05 #include <iostream>
06 using namespace std;
07
08 class Bunch
09 {
10 enum
11 {
12 size = 1000
13 };
14 int i[size];
15 };
16
17 int main()
18 {
19 cout << "sizeof(bunch) =" << sizeof(Bunch)
20 << ",sizeof(i[1000]) = "
21 << sizeof(int[1000]) << endl;
22 return 0;
23 }
24
25 /*
26 Output:
27 sizeof(bunch) =4000,sizeof(i[1000]) = 4000
28 */