Yes, it can be done. You can restrict visibility to public, protected, private keywords, as well as source visibility.
Declared visibility is usually understandable.
Source availability (if you are using Java) is slightly different.
Java: you have one file for the object / implementation interface. Cpp: you have one file for the interface. the implementation may consist of an interface or one or more implementation files (cpp, cxx).
If you use abstract classes / interfaces / functions, in addition to the public library interface, they are effectively hidden and inaccessible (well, this is not true if you have especially curious users who reset characters, then they can reuse the interface and the symbol link, but ... which is obviously undefined territory for them). Therefore, you only need to make the characters that you like visible. It is a good idea to use the package and library naming convention to avoid binding errors. Put the classes in the namespace reserved for the private library implementation. Plain.
It would be useful in C ++ ... it's not bad, although I personally think that there are higher priorities for the language.
source visibility example:
namespace MON { class t_button { protected: t_button(); virtual ~t_button(); public: typedef enum { Default = 0, Glowing = 1 } ButtonType; public: t_button* CreateButtonOfType(const ButtonType& type); }; } namespace MON { namespace Private { class t_glowing_button : public t_button { public: t_glowing_button(); virtual ~t_glowing_button(); public: }; } } MON::t_button* MON::t_button::CreateButtonOfType(const ButtonType& type) { switch (type) { case Glowing : return new Private::t_glowing_button(); case Default : return new Private::t_glowing_button(); default : break; } return 0; }
source share