On 2009-10-02 08:29:09 -0400, Max Samukha <spam...@d-coding.com> 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; }

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to