开发者

Hiding protected functions and members from the user?

开发者 https://www.devze.com 2023-01-25 05:09 出处:网络
My classes are event driven so for example, the public mouseClick() calls the protected onMouseClick().

My classes are event driven so for example, the public mouseClick() calls the protected onMouseClick().

I find that it might be puzzling if the user's开发者_StackOverflow社区 intellisense picks up on all the protected ones. Is there a way to minimize this confusion in any way?

Thanks


Member access control in C++ is for compilers, not for users. If you really need that, you should use ABCs as interfaces and create your objects through factories. This way you can make sure no end-user ever has to see any non-interface part of your code.


Good implementation of intellisense should not pick them up. I don't think there isn't much you can do to prevent it programatically.


The editorbrwsable atribute is used by intellisense to know wheter the user should see the method or not. While a blanket option is probably available in intellisense to hide protected functions, but if all else fails, you could use this.

0

精彩评论

暂无评论...
验证码 换一张
取 消