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; }
--
Michel Fortin
[email protected]
http://michelf.com/