If I have something like the following:
class A {
void foo(){ writeln(typeof(this)); }
...
}
class B : A {
...
}
And I want the results:
A a = new A;
B b = new B;
a.foo(); // prints "A"
b.foo(); // prints "B"
How would I go about doing that? At the moment b.foo() is
printing "A".
On Friday, 16 June 2017 at 13:46:14 UTC, Lester wrote:
If I have something like the following:
class A {
void foo(){ writeln(typeof(this)); }
...
}
class B : A {
...
}
And I want the results:
A a = new A;
B b = new B;
a.foo(); // prints "A"
b.foo(); // prints "B"
How would I go a
On Friday, 16 June 2017 at 13:46:14 UTC, Lester wrote:
If I have something like the following:
class A {
void foo(){ writeln(typeof(this)); }
try one of these:
http://dlang.org/spec/template.html#TemplateThisParameter
Though note that the this in there is still the static type at
the u
Thanks for the responses guys :)
I ended up using a foo(this T) and it works!
Thanks again for your help.