abstract class information

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed May 31 00:09:22 PDT 2017


On Wednesday, May 31, 2017 07:30:20 ag0aep6g via Digitalmars-d wrote:
> On 05/31/2017 12:19 AM, Jonathan M Davis via Digitalmars-d wrote:
> > Note that marking a class as abstract is equivalent to marking
> > all of its member functions with abstract, just like marking class with
> > @safe would make all of its member functions @safe. So, there isn't
> > really any special handling of marking the class itself as abstract.
>
> That's not true. A class's `abstract` attribute does not transfer to its
> methods. It's the other way around: Having an abstract method makes the
> class abstract.

Hmmm. That would make abstract inconsistent with other attributes on a
class, but after messing around with it a bit, it looks like the only effect
that marking a class with abstract has is how many times you get a linker
error about the member function not being defined. So, it looks like a I did
indeed remember incorrectly (or just misunderstood), but the behavior that
we do get with regards to putting abstract on the class is rather weird as
well as inconsistent with what happens with other attributes on a class. But
on reflection, that's probably because you wouldn't want to mark a function
with a body as abstract, meaning that marking abstract on a class would
either have to be ignored as it seems to be, or it would have to be ignored
on any function that has a body, which would probably cause problems with
.di files. So, I stand corrected.

- Jonathan M Davis



More information about the Digitalmars-d mailing list