   Access modifiers and inheritence
  I've got a class in a library that has a method I want to only be called by that class or derived classes, so I declare it protected:class desktop{protected:    virtual void   change_cursor( Cursor c ){}};I've found that the protected status isn't needed on derived classes:class glut_desktop : public desktop{public:    virtual void   change_cursor( Cursor c ){}};I've found this works using MSVC.net 2003, a glut_desktop* cast as desktop* and passed around calls the right change_cursor. Does anyone know what the official C++ spec says about it? Is it portable?   
  Well, yes, this is portable - but what's the point? You unprotect the change_cursor() method if the user is using a pointer to glut_desktop.glut_desktop my_desktop;glut_desktop *p_my_glut_desktop = &my_desktop;desktop *p_my_desktop = &my_desktop;p_my_destop->change_cursor(); // error: protectedp_my_glut_desktop->change_cursor(); // no error, because change_cursor() is publicThis is probaly not what you want. The whole access protection mecanism is to help you to avoid doing wrong things. Only interface methods should be public. A function you defined as not public in a class should not become public in a derived class.HTH,   ;  There is no point, I did it accidently and was curious as to why it worked. :)I'm not sure I even need the protected keyword there at all really. Quite often I'll use it by default when I know there is going to be a lot of inheritence occuring, but I'm never sure whether its better to use accessor methods rather than directly using the variables. As a rule of thumb I tend to try and only use variables directly in the classes they are definied in, I have no idea how this would affect performance though.   ;  Acces modifiers only work at compile-time, when the compiler uses them to check if you should be allowed to use the method.At run-time it has no influence (correct me if I'm wrong)   