The three virtues of a programmer: Laziness, Impatience, and Hubris. – Larry Wall

Extends clause

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

The extends clause is a mandatory part of class declarations (except for class Object) and an optional part of Interface declarations, state declarations and struct declarations. It defines that the declared item inherits members from the extended item. In case of classes and interfaces, the declared item is called subclass/subinterface or child class/interface of the extended item, while the extended class or interface is called superclass/superinterface or parent class/interface. Similar terminology could be used for extended states and structs, but is relatively uncommon there.

In Unreal Engine 1, the extends keyword can also be replaced by the keyword expands. That keyword is actually used by default when creating new classes via UnrealEd and very early versions of the Unreal Engine will not recognize the keyword extends.

Syntax[edit]

The most common use of an extends clause is a class declaration:

class ClassName extends ParentClass;

The extends clause of a class declaration can be followed by a within clause and optional class modifiers.

Other usages of the extends clause are rare, but one example available in all Unreal Engine games is the Plane struct:

struct Plane extends Vector
{
	var() config float W;
};

This declaration inherits the X, Y and Z components of the Vector struct and adds the W component.