Reputation: 5
Hi I've been asked to set my arrays that contain 3d cube information to "null" so that they can be used to take in the data that is required to draw them from a txt file but have run int this error.
Any help would be appreciated.
cube header file
class Cube
{
private:
static int numVertices, numColours, numIndices;
static Vertex indexedVertices[];
static Color indexedColors[];
static GLushort indices[];
GLfloat _rotation;
GLfloat _CubeX;
GLfloat _CubeY;
GLfloat _CubeZ;
Cube cpp file
Vertex *Cube::indexedVertices = nullptr;
Color *Cube::indexedColors[] = nullptr;
GLushort *Cube::indices[] = nullptr;
The error appears under indexedVertices , indexedColors and indices
Upvotes: 0
Views: 362
Reputation: 58947
Arrays can't be null.
Also, you didn't specify the size of the arrays in their definitions.
Also, your definitions don't match your declarations! Compare:
static Vertex indexedVertices[]; // declares an array of Vertexes
Vertex *Cube::indexedVertices = nullptr; // defines a pointer to a Vertex
Also compare:
static Color indexedColors[]; // declares an array of Colors
Color *Cube::indexedColors[] = nullptr; // defines an array of pointers to Colors
Arrays are not pointers. Sometimes the language will "helpfully" convert arrays to pointers for you (e.g. indexedVertices
is converted to &indexedVertices[0]
when used in an expression), but they are not the same thing!
Upvotes: 2