Namespaces like C++
rjframe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jan 16 10:36:44 PST 2017
On Mon, 16 Jan 2017 18:02:09 +0000, Andrey wrote:
> Hello, can I using namespaces like in C++, for example: ui::Widget or
> ui::Manager? I created ui/widget.d and ui/manager.d for implementation
> classes Widget and Manager, bun I can't import their correctly for using
> ui.Manager uiManager;
> If it is impossible, then what is the best way to using namespaces in D?
> Should I naming my classes with prefix e.g. UIManager and UIWidget?
You can do either a static import or renamed import. The static import
requires using the fully-qualified name; renamed imports let you set a
local name for the module.
static import ui.widget;
ui.widget.SomeWidget w;
import mymanager = ui.manager;
mymanager.uiManager m;
For more information on modules see http://dlang.org/spec/module.html
--Ryan
More information about the Digitalmars-d-learn
mailing list