Search⌘ K
AI Features

typeid and TypeInfo

Explore how the Object class in D provides key member functions and how the typeid expression and TypeInfo class deliver runtime type information. Understand how to compare types and obtain runtime type names to enhance type handling in D programming.

We'll cover the following...

Object

Classes that do not explicitly inherit any class, automatically inherit the Object class.

By that definition, the topmost class in any class hierarchy inherits Object:

// Inherits Object indirectly
class StringInstrument : MusicalInstrument {
    // ...
}

Since the topmost class inherits Object, every class indirectly inherits Object ...