Classes

In addition to interfaces, Slice permits the definition of classes. Classes are like structures on steroids, with inheritance and the ability to hold optional data members.

Classes, unlike structures, have "pointer" semantics: a data member is a pointer to class instance that can be shared by multiple data members. A class data member or parameter can also be null, meaning it does not point to anything; this is unlike a struct data member or parameter that can never be null.

Classes support inheritance and are therefore polymorphic: at run time, you can pass a class instance to an operation as long as the actual class type is derived from the formal parameter type in the operation's signature.

Topics