static data in a sub-class
Ali Çehreli
acehreli at yahoo.com
Sat Dec 22 18:41:51 PST 2012
On 12/22/2012 01:37 PM, Steve D wrote:
> I will continue playing with your suggestions etc to see
> what's cleanest.
Both of those options have unnecessary costs. If everything is known at
compile time, you can use the curiously recurring template pattern:
import std.stdio;
class A(SubT) {
final void f() { writefln("hi %s", SubT.hi); }
}
class B : A!B {
static float[3] hi = 2;
}
void main()
{
B b = new B();
b.f();
}
Ali
More information about the Digitalmars-d-learn
mailing list