RE: [GD-General] not sure where to post this question... bit C++ implementation specific....
Brought to you by:
vexxed72
From: Crosbie F. <cr...@cy...> - 2004-07-07 10:03:21
|
> From: Jorrit Tyberghein > How would that help? In C++ you simply cannot do this: >=20 > int a =3D 6; > int array[a]; >=20 > It is not possible to allocate arrays with variables (const=20 > or not const). Many apologies for the following hack, but once upon a time it was = needed. #if 0 #define CLASS_INT(N) _SClassInt##N #define CLASS_INT_STRUCT(N) typedef char CLASS_INT(N) [N] CLASS_INT_STRUCT(2); CLASS_INT_STRUCT(3); CLASS_INT_STRUCT(4); =09 #undef CLASS_INT_STRUCT #define NUMBER(NN) CLASS_INT(NN) #else #define NUMBER(NN) char [NN] #endif #define _2 NUMBER(2) #define _3 NUMBER(3) #define _4 NUMBER(4) #define INT_(NUM) (sizeof(NUM)) Maybe it could be used again? e.g. int array[INT_(NUMBER(6))]; But, there MUST be a better answer these days eh? Templates perhaps? |