Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 05, 2020 Abstract override behaviour | ||||
---|---|---|---|---|
| ||||
Hi dlang community, Just started to learn D using Visual Studio 2007, latest VisualD (VisualD-v0.51.0-dmd-2.090.0-ldc2-1.19.0) and "The D Programming Language" by Andrei Alexandrescu. I am trying to run most of the examples and had a surprise at chapter 1.6.1 "More Statistics. Inheritance" with the following code: interface Stat { void accumulate(double x); ... } class IncrementalStat : Stat { ... abstract void accumulate(double x); ... } class Min : IncrementalStat { ... void accumulate(double x) { ... } ... } In class "Min" definition I am receiving this error: "cannot implicitly override base class method `IncrementalStat.accumulate` with `Min.accumulate`; add `override` attribute" After I update "Min" class to << override void accumulate(double x) >> everything works fine. Can anybody clarify where is the problem. Thanks in advance, Claudiu |
February 05, 2020 Re: Abstract override behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Claudiu | On 2/5/20 8:49 AM, Claudiu wrote: > In class "Min" definition I am receiving this error: "cannot implicitly override base class method `IncrementalStat.accumulate` with `Min.accumulate`; add `override` attribute" Andrei's book is a little dated. Here is the errata: http://erdani.com/index.php?cID=109 Ali |
February 05, 2020 Re: Abstract override behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Wednesday, 5 February 2020 at 16:55:42 UTC, Ali Çehreli wrote:
> On 2/5/20 8:49 AM, Claudiu wrote:
>
>> In class "Min" definition I am receiving this error: "cannot implicitly override base class method `IncrementalStat.accumulate` with `Min.accumulate`; add `override` attribute"
>
> Andrei's book is a little dated. Here is the errata:
>
> http://erdani.com/index.php?cID=109
>
> Ali
Thanks a lot, I'll need to keep this errata close for future "surprises". I'm trying to learn idiomatic D. I think that this book is still relevant, but are there other recommended books?
|
February 05, 2020 Re: Abstract override behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Claudiu | On Wednesday, 5 February 2020 at 17:11:28 UTC, Claudiu wrote: > > Thanks a lot, I'll need to keep this errata close for future "surprises". I'm trying to learn idiomatic D. I think that this book is still relevant, but are there other recommended books? https://p0nce.github.io/d-idioms/#Which-book-should-I-read? |
Copyright © 1999-2021 by the D Language Foundation