C/C++:const??????define?????????
???????????? ???????[ 2014/1/22 10:04:52 ] ?????????????? C++ const ????
?????????????????г????const?????????????÷?????????????????δ????????????????????SIZE?????????
class A
{…
const int SIZE = 100; // ????????????????г????const??????
int array[SIZE]; // ????δ???SIZE
};
const????????????????????????????????н??У?????
class A
{…
A(int size); // ??????
const int SIZE ;
};
A::A(int size) : SIZE(size) // ??????????????
{
…
}
A a(100); // ???? a ??SIZE??100
A b(200); // ???? b ??SIZE??200
????????????????????????ж????????????????const?????????????????е?????????????????
class A
{…
enum { SIZE1 = 100?? SIZE2 = 200}; //??????
int array1[SIZE1];
int array2[SIZE2];
};
?????????????????????洢???????????????????????????????????????????????????????????????????????????????????????PI=3.14159????sizeof(A) = 1200;?????????????
????enum EM { SIZE1 = 100?? SIZE2 = 200}; //?????? sizeof??EM?? = 4??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11