65,211
社区成员
发帖
与我相关
我的任务
分享
#define countof( array ) ( sizeof( array )/sizeof( array[0] ) )
int* pInt = new int[100];
int nArraySize = countof(pInt);
template <typename T, size_t N>
char ( &_ArraySizeHelper( T (&array)[N] ))[N];
#define countof( array ) (sizeof( _ArraySizeHelper( array ) ))
template <typename T, size_t N>
char ( *_ArraySizeHelper( T (&array)[N] ))[N];
#define countof( array ) (sizeof(*_ArraySizeHelper( array ) ))