O'Reilly logo

Learn to Tango with D by Sean Kelly, Michael Parker, Kris Macleod Bell, Lars Ivar Igesund

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. D's Object-Oriented Features

All the programming languages in the C family provide a way to encapsulate data and operations through the simple struct or the more complex class. D includes support for both classes and structs, but the rules that govern their usage may not be what you are used to from other C languages. For example, D structs are similar to those found in C++ in that they may have methods, but unlike C++ structs, they may not be extended through inheritance. Classes in D are similar to those found in Java in that only single inheritance is supported. Also as in Java, a D class may implement multiple interfaces.

While structs and classes are the main means to encapsulate in D, the language provides a default encapsulation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required