Re: How polymorphism work in D?

2019-11-06 Thread ShadoLight via Digitalmars-d-learn
On Wednesday, 6 November 2019 at 06:27:32 UTC, OiseuKodeur wrote: On Wednesday, 6 November 2019 at 06:05:25 UTC, rikki cattermole wrote: On 06/11/2019 6:43 PM, OiseuKodeur wrote: I have this [snip] Rikki's answer is the direct answer to your question since you already had the if(..)

Re: How polymorphism work in D?

2019-11-05 Thread OiseuKodeur via Digitalmars-d-learn
On Wednesday, 6 November 2019 at 06:05:25 UTC, rikki cattermole wrote: On 06/11/2019 6:43 PM, OiseuKodeur wrote: I have this ``` import std.stdio : writeln; abstract class Foo { } class Bar : Foo {     float value;     this(float t_value) { value = t_value; } } class Baz : Foo {    

Re: How polymorphism work in D?

2019-11-05 Thread rikki cattermole via Digitalmars-d-learn
On 06/11/2019 6:43 PM, OiseuKodeur wrote: I have this ``` import std.stdio : writeln; abstract class Foo { } class Bar : Foo {     float value;     this(float t_value) { value = t_value; } } class Baz : Foo {     string name;     this(string t_name) { name = t_name; } } void main() {

How polymorphism work in D?

2019-11-05 Thread OiseuKodeur via Digitalmars-d-learn
I have this ``` import std.stdio : writeln; abstract class Foo { } class Bar : Foo { float value; this(float t_value) { value = t_value; } } class Baz : Foo { string name; this(string t_name) { name = t_name; } } void main() { Foo foo = new Bar(10); if (/* typeof