Skip to content

Namespace Inheritance

In Bjarne language, namespaces can limit the access to their subordinate symbols with the access modifier keywords: public, protected, and private. Like C++ classes, all subordinate symbols are implicitly private, and protected symbols are accessible from decendant namespaces. Subordinate symbols cannot be overriden.

namespace supermodule
{
    // ...
}

namespace extended : public supermodule // acquires the access to all public and protected subordinate symbols of the supermodule namespace.
{
}
namespace supermodule
{
    // ...
}

namespace extended : private supermodule // acquires the access to all public and protected subordinate symbols of the supermodule namespace, but mark them private.
{
}
namespace supermodule
{
    // ...
}

namespace extended : protected supermodule // acquires the access to all public and protected subordinate symbols of the supermodule namespace, but mark them protected.
{
}