On Fri, 2 Oct 2009 08:54:49 -0400, Michel Fortin <[email protected]> wrote:
>On 2009-10-02 08:29:09 -0400, Max Samukha <[email protected]> said: > >> class Counted { >> mixin(Derived) >> { >> // Insert here stuff that must be "pasted" for each subclass >> // of Counted (including Counted itself). >> // Use "Derived" as the name of the current subtype of >> Counter >> private static uint _counter; >> uint staticCounter() { return _counter; } >> >> static if (is(Counted == Derived)) >> uint getCounter() { return staticCounter; } >> else >> override uint getCounter() { return staticCounter; } >> } >> ... >> } >> >> The counter variable is now incapsulated. > >Hum, I think you forgot to make staticCounter static, as in: > > static uint staticCounter() { return _counter; } Yes, I do it all the time. Thanks!
