Reputation: 680
I have this header (with hidden code):
class DrawBuffers
{
public:
struct CubeCorners
{
GLfloat corners[NUM_VERTS * ELEM_PER_NORM];
CubeCorners(bool normalize);
};
static const CubeCorners POSITIONS;
static const GLfloat COLOR_DEFAULT[ELEM_PER_COLOR];
static const CubeCorners NORMALS;
static const GLuint INDICES[NUM_INDICES / NB_FACES][NB_INDICES_PER_FACE];
};
I have this in the cpp:
const DrawBuffers::CubeCorners POSITIONS = DrawBuffers::CubeCorners(false);
const GLfloat DrawBuffers::COLOR_DEFAULT[] = {1.f, 1.f, 1.f, 1.f};
const DrawBuffers::CubeCorners NORMALS = DrawBuffers::CubeCorners(true);
const GLuint DrawBuffers::INDICES[][NB_INDICES_PER_FACE] = { //second indices
{0, 1, 2, // Back
2, 3, 0},
{7, 6, 5, // Front
5, 4, 7},
{4, 5, 1, // Left
1, 0, 4},
{3, 2, 6, // Right
6, 7, 3},
{4, 0, 3, // Bottom
3, 7, 4},
{6, 2, 1, // Top
1, 5, 6}};
And I still get an undefined reference to POSITIONS in the same .cpp file... Anything I may have forgotten?
Thank you! :)
Upvotes: 0
Views: 363
Reputation: 254691
These are static members, so you need to qualify the names in their definitions (as you've already done with two of them):
const DrawBuffers::CubeCorners DrawBuffers::POSITIONS = DrawBuffers::CubeCorners(false);
^^^^^^^^^^^^^
You've instead declared static non-member variables.
Upvotes: 1