Sep 1, 2010 at 7:18pm
Hi there, I'm a bit new to C++, but not programming in general.
I have no idea why this code:
1 2 3
|
4| float densityList[2];
5| densityList[0] = 6.0F;
6| densityList[1] = 13.0F;
|
Is generating this error:
...\arrays.cpp(5) : error C2466: cannot allocate an array of constant size 0 |
Line 5 is causing the error, but I'm not
trying to create a zero length array, I want to set the value for the first item in the array.
I'm sure I'm missing some basic syntax but from the arrays page here it all seems to be in order.
Last edited on Sep 1, 2010 at 7:22pm
Sep 1, 2010 at 7:46pm
Thats basically it, its just a long list of Arrays (no main function). They all get that error though.
Sep 1, 2010 at 8:07pm
Well the code you posted works, so the problem must be elsewhere. You'll have to post more code if you'll want us to spot the problem.
Sep 1, 2010 at 8:33pm
Are you sure you don't have those line outside a function?
Sep 2, 2010 at 7:30am
okay, will try that after work, thanks.