class Monster :Creature {
static float[3] hi = 1;
this(float[] x=null) {if (x) hi = x;}
That is a bad idea. x is passed to a single Monster object but
the 'hi' static member of the whole Monster class gets affected.
Just because there is a SwiftMonster, all Monsters become swift.
Yep I know
On 12/23/2012 02:08 PM, Steve D wrote:
> Let's say it's a game and the objects are creatures.
Thanks for giving more context. It helps to see meaningful names to
understand code better.
> class Creature {
> abstract void move();
> }
That's very reasonable.
> class Monster :Creature {
> stat
Thanks Ali, I'm still playing with your earlier suggestion of
passing the array to A in a super() call from B.
But now... I dunno things are getting worse... it 'sometimes'
works see below..
While we're chatting, I've slightly added to the earlier example
to better replicate my actual code.
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) {
On Saturday, 22 December 2012 at 21:14:58 UTC, Ali Çehreli wrote:
On 12/22/2012 12:44 PM, Steve D wrote:
Hello,
How can I get class B's array printed, using inherited A's
function?
(Dmd 2.060)
class A {
static float[3] hi = 1;
void f() { writefln("hi %s",hi); }
}
class B : A {
static float[
On Saturday, 22 December 2012 at 21:04:47 UTC, Jonathan M Davis
wrote:
On Saturday, December 22, 2012 21:44:33 Steve D wrote:
Hello,
How can I get class B's array printed, using inherited A's
function? (Dmd 2.060)
class A {
static float[3] hi = 1;
void f() { writefln("hi
On 12/22/2012 12:44 PM, Steve D wrote:
Hello,
How can I get class B's array printed, using inherited A's function?
(Dmd 2.060)
class A {
static float[3] hi = 1;
void f() { writefln("hi %s",hi); }
}
class B : A {
static float[3] hi = 2;
}
B b = new B();
b.f(); // prints 'hi [1,1,1]'
// can I g
On Saturday, December 22, 2012 21:44:33 Steve D wrote:
> Hello,
> How can I get class B's array printed, using inherited A's
> function? (Dmd 2.060)
>
> class A {
> static float[3] hi = 1;
>
> void f() { writefln("hi %s",hi); }
> }
>
> class B : A {
> st
Hello,
How can I get class B's array printed, using inherited A's
function? (Dmd 2.060)
class A {
static float[3] hi = 1;
void f() { writefln("hi %s",hi); }
}
class B : A {
static float[3] hi = 2;
}
B b = new B();
b.f(); // prints 'hi [1,1,