In C# I can generate a static array using a function:
private static readonly ushort[] circleIndices = GenerateCircleIndices();
....
private static ushort[] GenerateCircleIndices()
{
ushort[] indices = new ushort[MAXRINGSEGMENTS * 2];
int j = 0;
for (ushort i = 0; i < MAXRINGSEGMENTS; ++i)
{
indices[j++] = i;
indices[j++] = (ushort)(i + 1);
}
return indices;
}
Using C++ I believe the following is the correct way to generate a static array:
.h
static const int BOXINDICES[24];
.cpp (constructor)
static const int BOXINDICES[24] =
{
0, 1, 1, 2,
2, 3, 3, 0,
4, 5, 5, 6,
6, 7, 7, 4,
0, 4, 1, 5,
2, 6, 3, 7
};
How can I do the same for the circleIndices but use a function to generate the values?
.h
static const int CIRCLEINDICES[];
.cpp (constructor)
static const int CIRCLEINDICES[] = GenerateCircleIndices(); // This will not work
Do I have to initialise the array elements with values of 0 then call the function?