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

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

Prestwood eMagazine

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

   ► KBProgrammingDelphi for W...OOP   Print This     
  From the August 2010 Issue of Prestwood eMag
Delphi OOP:
Delphi Class Members (Class)
Posted 15 years ago on 12/25/2008
Delphi Code Snippet:
 A flashcard from our Delphi Flashcards Library
 A code snippet from our Delphi Code Snippets Page


General Info: Static Class / Static Member

A static member is a member you can have access to without instantiating the class into an object. For example, you can read and write static properties and call static methods without ever creating the class. Static members are also called class members (class methods, class properties, etc.) since they belong to the class and not to a specific object. A static class is a class that contains only static members. In the UML, these classes are described as utility classes.

Languages Focus: Static Member

Languages that support static members usually at least support static member fields (the data). Some languages also support static methods, properties, etc. in which case the class member is held in memory at one location and shared with all objects. Finally, some languages support static classes which usually means the compiler will make sure a static class contains only static members.

Delphi Class Members

Object Pascal supports static methods, but not static member fields. For static member fields, use traditional Pascal-like global variables.

Since Object Pascal is a hybrid language, you can use global functions and data so the need for class methods is diminished but still useful. For example, since Object Pascal does not have automatic reference counting, you could use a class method to keep track of the number of object instances.

Delphi 1-7: All classes in a unit are friendly (see eachother's private members), some developers like to put each class in it's own unit and reserve putting multiple classes in the same unit until they wish to implement friendly classes.

Delphi 2005+: New strict keyword allows you to indicate friendly.

Delphi Prism: The Strict keyword was introduced from the beginning (Delphi.Net preview that shipped with D7).

Syntax Example:
TMyUtils = class(TObject)
class function MyStaticMethod: Integer;

In implimentation:

class function TMyUtils.MyStaticMethod: Integer;

More Info

Definition:  Static Class / Static Member


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

An asked document and paper is very nice for the formatting for the students. All the shows of the chunk and are invited for the spices. The path is formed for the rule of the trial for the basis for the situation for the gaols for the festivals for options.

Posted 26 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 = P1257A1
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

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

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