Working with objects

If you have experience with object-oriented programming, you'll find much of D's OOP support familiar. As such, I need to reiterate my warning from before: D is not C++, Java, or C#. Familiarity can help you pick some things up more quickly, but it can also lead you to take other things for granted. This section introduces D's OOP features.

Encapsulation with protection attributes

There are four levels of protection in D: public, package, private, and protected. The first three apply to classes, structs, and modules, but protected only has meaning with classes. We'll examine it later when we talk about inheritance.

Public

Anything declared public in a module, whether it's in module scope or as part of a class or struct declaration, ...

Get Learning D now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.