Paint() access

Not that important, but I'm often asking myself why so many "void paint (Graphics&)" are public.
Is there some cases where they are accessed directly from outside ?
In my own components, I tend to set the paint, resized and mouse listener functions protected or even private.
Is it fine, or is there anything particular I should think about before doing so?


Well, as far as I know access control is a compiler feature ... so if it compiles, you've won... :)

Unless there's some future feature you might end up mucking up.

I suppose I had to call my own mouse listener functions the other day from somewhere else. But I was trying to do something stupid...

Generally, protected inheritance isn't considered a good thing - there are articles out there that explain at great length why that's the case, but a general rule of thumb is that it's best to generally either make a method public or private. In this case you could make it private, but then that'd prevent other subclasses from overriding it, so public is probably the best. And although there's probably no reason why other classes would want to access it, there's also no reason why you'd want to stop them doing that if there was some reason for doing so.

I'm not sure I agree with the arguments though.  I use it regularly where I have a tight family of objects and need them to share some basic data structure. 

I can see it'd be less useful in a library that was going to be used by a lot of people.  But inside my own stuff it ensures that a change to the protected method won't cause repercussions in every bloody source file at least :)