You could be forgiven for expecting this to work, if called from within a non-static member function of myClass. For instance, this works:
GLuint x = myClass::id;
More mysteriously, this works too:
glGenBuffers(1, &(myClass::id));
Similarly:
GLuint *p = &myClass::id; // Doesn't work!
GLuint *p = &(myClass::id); // Works!
As John Dibling wrote, in general the solution is simply to omit the scope qualifier:
GLuint x = id;
glGenBuffers(1, &id);
But this won't work if you are trying to access a member in a base class that has the same name. So what is the difference between &myClass::id and &(myClass::id)? I wish I could tell you, but I can't figure it out! The scope operator :: has the highest precedence of all the C++ operators, so I would expect them to be equivalent. Can anybody put me right?
Edited to add: OK, it all makes some kind of sense. In the draft standard N3337 for C++0x, it says:
The result of the unary & operator is a pointer to its operand. The
operand shall be an lvalue or a qualified-id. If the operand is a
qualified-id naming a non-static member m of some class C with type T, the result has type “pointer to member of class C of type
T” and is a prvalue designating C::m. Otherwise...
Then you go and look up what a qualified_id is, and it turns out that if you put it in parentheses, it's not a qualified_id any more. Which explains everything.