[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'System' (#rtl)

# TObject

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Base class of all classes.

## Declaration

Source position: objpash.inc line 201

`type TObject = class`
`public`
`constructor Create;` |  | TObject Constructor
`destructor Destroy; virtual;` |  | TObject destructor.
`class function newinstance; virtual;` |  | Allocate memory on the heap for a new instance
`procedure FreeInstance; virtual;` |  | Clean up instance and free the memory reserved for the instance.
`function SafeCallException(); virtual;` |  | Handle exception object
`procedure DefaultHandler(); virtual;` |  | Default handler for integer message handlers.
`procedure Free;` |  | Check for Nil and call destructor.
`class function InitInstance();` |  | Initialize a new class instance.
`procedure CleanupInstance;` |  | Finalize the class instance.
`class function ClassType;` |  | Return a "class of" pointer for the current class
`class function ClassInfo;` |  | Return a pointer to the type information for this class.
`class function ClassName;` |  | Return the current class name.
`class function ClassNameIs();` |  | Check whether the class name equals the given name.
`class function ClassParent;` |  | Return the parent class.
`class function InstanceSize;` |  | Return the size of an instance.
`class function InheritsFrom();` |  | Check whether class is an ancestor.
`class function StringMessageTable;` |  | Return a pointer to the string message table.
`class function MethodAddress();` |  | Return the address of a method
`class function MethodName();` |  | Return the name of a method.
`function FieldAddress();` |  | Return the address of a field.
`procedure AfterConstruction; virtual;` |  | Method called after the constructor was called.
`procedure BeforeDestruction; virtual;` |  | Method called before the destructor is called.
`procedure DefaultHandlerStr(); virtual;` |  | Default handler for string messages.
`procedure Dispatch(); virtual;` |  | Dispatch an integer message
`procedure DispatchStr(); virtual;` |  | Dispatch a string message.
`function GetInterface();` |  | Return a reference to an interface
`function GetInterfaceByStr();` |  | Return an interface based on its GUID
`function GetInterfaceWeak();` |  | Get a reference to an interface, not increasing the reference count
`class function GetInterfaceEntry();` |  | Return the interface table entry by GUID
`class function GetInterfaceEntryByStr();` |  | Return the interface table entry by string
`class function GetInterfaceTable;` |  | Return a pointer to the table of implemented interfaces for a class
`class function UnitName;` |  | Unit name
`class function QualifiedClassName;` |  | Fully qualified classname
`function Equals(); virtual;` |  | Check if two objects are equal.
`function GetHashCode; virtual;` |  | Return a hash code for the object
`function ToString; virtual;` |  | Return a string representation for the object
`end;`

## Inheritance

`TObject` |  | Base class of all classes.

## Description

TObject is the parent root class for all classes in Object Pascal. If a class has no parent class explicitly declared, it is dependent on TObject. TObject introduces class methods that deal with the class' type information, and contains all necessary methods to create an instance at runtime, and to dispatch messages to the correct method (both string and integer messages).

## See also

TClass |  | Class of TObject.