Re: [GD-General] not sure where to post this question... bit C++ =?windows-1252?q?=09implementation?
Brought to you by:
vexxed72
From: Noel L. <nl...@co...> - 2004-07-07 13:52:26
|
On Wednesday 07 July 2004 05:23 am, Richard Fabian wrote: > i seem to be able to safely issue declarations for int initialised > arrays... > > e.g. > > const int ropeLength = 12.5f; > const int knotSpace = 3.3f; > int array[ (int)( ropeLength / knotSpace ) ]; > > is perfectly valid. > > it looks like it is quite literally the "const float"s that are at > fault. If I recall correctly, const floats were treated very differently from const ints in VC++. Const floats even generated their own bit of code to be executed when they were initialized, whereas const ints became true consts, so it doesn't surprise me that they can't be used as part of the array size. As some other people pointed out earlier, any reason not to use an std::vector<> or do dynamic allocation? If you don't like having to delete the memory, you can always use boost::scoped_array: boost::scoped_array<int> array (new[ (int)( ropeLength / knotSpace ) ]); --Noel Games from Within http://www.gamesfromwithin.com |