Ok, so this is a really basic question (or at least I think so).
What I'm trying to do is to use the default constructor to create an array of type beams that is numElements long.
I'm using gcc-g++ version 4.1.2 and I'm getting the following error:
error: array bound forbidden after parenthesized type-id
note: try removing the parentheses around the type-id
I've learned that this syntax was allowed in gcc-g++ versions prior to 4.0, but was then disallowed (for what ever reason).
Following the hint from the compiler actually makes the code compile, but I get an error at runt time. I guess this is due to that the statement is enterpreted as something else when leaving out the parantheses and this is where I get confused.
How can I write an equivalent expression without using the parantheses?
Yes. new beams[numElements]; gives you an array of beams.
new beams*[numElements]; would give you an array of pointers, not beams (you might do this if you want a 2D "nested new" array - though I don't recommend that approach)
From your description, it does not sound like you want a 2D array.
A 1D array would look like this:
1 2 3 4 5 6 7 8
// creation
beams* beam = new beams[numElements];
// accessing a single element
beam[x].whatever();
// cleanup
delete[] beam;
A 2D array would look like this:
1 2 3 4 5 6 7 8 9 10 11 12
// creation
beams** beam = new beams*[height];
for(int i = 0; i < height; ++i)
beam[i] = new beams[width];
// accessing a single element
beam[y][x].whatever();
// cleanup
for(int i = 0; i < height; ++i)
delete[] beam[i];
delete[] beam;