equivalent of c++ private inheritance with using

Jonathan M Davis jmdavisProg at gmx.com
Fri Oct 12 16:05:02 PDT 2012


On Friday, October 12, 2012 23:10:47 Dan wrote:
> What is best way to get equivalent of C++ private inheritance
> combined with using declarations in the drived to expose some
> functionality. For example, suppose I want a basic RateCurve
> class that defers almost entirely to type Array as below. The
> problem is, once RateCurve is moved to a different module, the
> private impl prevents it from working:

You can have the variable be private and alias a function which returns by ref 
instead of the variable itself. Something like

class C
{
 @property ref inout(Impl) get() inout { return _impl; }
 alias get this;

private:
 Impl _impl;
}

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list