A CeePlusPlus idiom where a class is used as a namespace, in order to implement pseudo-packages. Some say this is unnecessary, given that C++ also has namespaces. However, it is occasionally useful.
Consequences:
- Generally, such a class will only have static members (or else be a singleton); though with the potential to turning into full-fledged objects.
- Unlike namespaces, which are "open" scopes (any translation unit/header/file/etc. can add stuff to a namespace and the linker is responsible for dealing with collisions), PackageClasses are closed scopes. They must be defined in exactly one place.
- As they are classes, you can do with them anything you can do with any other class--make them friends of something, inherit from them, etc.
- Access control works; you can have private members of the class and thus limit your external API to the public parts.
This works well enough in JavaLanguage too. Of course, Java has true "packages"; which are similar to the
PackageClass (except that they are singletons by default).
See also PackageDesign