Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Learning C++ const reference

Name: Anonymous 2011-12-10 11:09

Hi, guys... I'm trying to learn C++ and OpenGL...

I want to return the first pointer of the array... but maintaing the const correctness...


it happened that:

class Foo{
private:
    GLint array[64][64][4];
public:
    const GLint& get_array(){return array;}
}


gives me this compiler error:


/Users/Pella/Desktop/c/OpenGL_Nehe_cpp/CheckImag.h:28:0 /Users/Pella/Desktop/c/OpenGL_Nehe_cpp/CheckImag.h:28: error: invalid initialization of reference of type 'const GLubyte&' from expression of type 'GLubyte (*)[64][4]'



can you help me out in understanding the const correctness?

Name: Anonymous 2011-12-10 11:50

>>1

found the solution, but anyway thank you:

    const GLubyte*  get_array(){return (GLubyte*)array;}

probably I have expressed myself wrong...

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List