RE: [GD-General] not sure where to post this question... bit C++ implementation specific....
Brought to you by:
vexxed72
From: Luis V. <lui...@mi...> - 2004-07-07 19:06:29
|
AFAIK the C++ standard disallows declaring arrays with float variables. Array declarations require "integral constant expressions" which allow floating literals to be part of the constant as long as a cast is present to transform these to either integral or enumeration types. "integral constant expressions" do not allow float variables (even if they are constant) In your first example "const int a" is an "integral constant expression" because it is a const int. In the second example 5.4f and 3.6f are both floating literals and which are casted to an int. The third example uses const floats which are not part of the definition of "integral const expressions"; therefore the compiler rejects the code. Luis Villegas -----Original Message----- From: gam...@li... [mailto:gam...@li...] On Behalf Of Andras Balogh Sent: Wednesday, July 07, 2004 8:41 AM To: gam...@li... Subject: RE: [GD-General] not sure where to post this question... bit C++ implementation specific.... > 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 or not const). I dunno, this compiles fine on MSVC++: const int a =3D 6; int array[a]; This also works fine: const int a =3D static_cast<const int>(5.4f / 3.6f); int array[a]; But then why it's not possible to do: const float a =3D 14.5f; const float b =3D 2.3f; const int c =3D static_cast<const int>(a / b); int array[c]; ? Andras ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 -=20 digital self defense, top technical experts, no vendor pitches,=20 unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ Gamedevlists-general mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-general Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D557 |