Your full service technology partner! 
-Collapse +Expand
Search Delphi Group:

-Collapse +Expand Delphi To/From
-Collapse +Expand Delphi Store

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingDelphi for W...OOP   Print This     
  From the August 2015 Issue of Prestwood eMag
Delphi OOP:
Delphi Base Class (TObject)
Posted 14 years ago on 10/24/2008 and updated 2/9/2009
Delphi Code Snippet:
 A flashcard from our Delphi Flashcards Library
 A code snippet from our Delphi Code Snippets Page
 Tags: Delphi , Base Class


Languages Focus: Base Class

When you create a class, it is either a base class or inherits from another class. Some languages require all classes to inherit from a common base class and some do not.

Delphi Base Class

In Delphi programming language (Object Pascal), all classes ultimately inherit from the base class TObject.

Syntax Example:
//Specify both namespace and class:
TCyborg = class(System.TObject)
//Use shortcut alias:
TCyborg = class(TObject)
//None, default is System.TObject
TCyborg = class

Fun With TObject

TObject has some basic functionality available for all Delphi classes. Since TObject is the base class for Delphi, you should become familiar with it's features.

To see TObject in action, alter the click event of a button as follows:

  MyObject: TObject;

  MyObject := TObject.Create;       //Create object instance.
  ShowMessage(MyObject.ClassName);  //Return the class name.
  ShowMessage(UnitName);            //UnitName is a class function
                                    //defined in TObject.
//Free object instance.

Next, view the source code for TObject to see what routines are implemented. The easiest way to find TObject's declaration is to right click on TObject in your source code and select Find Declaration. Most of these routines are documented in the help so you can place the cursor on any procedure or function name and press F1.

Common Inheritance Choices

The following is a short list of some more common VCL classes you can inherit from.

Class Use For Features / Notes
TObject demos create, destroy
TPersistent streaming objects

Save object

TObject >> TPersistent

TComponent non-visual classes

Ability to appear on the Component / Tool palette and to be manipulated in the Form Designer.

TObject >> TPersistent >> TComponent

TControl visual classes

Visual elements like OnClick, OnDblClick, Top, Left, etc.

TObject >> TPersistent >> TComponent >> TControl

IInterface Interfaces Base interface class.
IUnknown Win 32 Specific Interfaces For Win32 specific interfaces.

Step by Step Example

The following is a step-by-step tutorial on creating your first Delphi class and does include an inheritance example. From this simple tutorial, you can then experiment with the various class inheritance features.

More Info


Share a thought or comment...
Comment 1 of 1

Document and all review is casual for the approach for all officials. The ting of the team and for the terms. The final attempt is made for the goals for the turns for all’s how’s for all chipped items or the tenets for all issues.

Posted 20 months ago
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P121A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

Linked Certification Question(s)

The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.


1 Intermediate Level Question

Question #1: Multiple Choice

Given the following three code snippets:

1. TPerson = class(TObject)
2. TPerson = class
3. TPerson = class(System.TObject)

Which of the following statement is most accurate?


All three are equivalent.


1 and 3 are equivalent, 2 will not even compile.


2 and 3 are equivalent, 1 will not even compile.


1 and 2 are equivalent, 3 will not even compile.

 KB Article #101411 Counter
Since 10/24/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site:

©1995-2022 Prestwood IT Solutions.   [Security & Privacy]