IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Prism
Search Prism Group:

Advanced
-Collapse +Expand Prism To/From
To/FromCODEGuides
-Collapse +Expand Prism Study Test
PRESTWOODCERTIFIED
-Collapse +Expand Prism Store
PRESTWOODSTORE

Prestwood eMagazine

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

   ► KBProgrammingDelphi PrismOOP   Print This     
  From the October 2015 Issue of Prestwood eMag
 
Prism OOP:
Delphi Prism Member Modifiers
 
Posted 17 years ago on 12/22/2008 and updated 1/28/2009
Prism Code Snippet:
 A flashcard from our Prism Flashcards Library
 A code snippet from our Prism Code Snippets Page

KB101735

Languages Focus: Member Modifier

Traditional private, protected, public, etc. member modifiers are documented under the member visibility topic of the Cross Reference Encyclopedia. With member modifiers here, we address additional member modifiers such as method and field modifiers.

Delphi Prism Member Modifiers

Prism supports a full suite of member modifiers. Prism virtuality modifiers are virtual, override, final, and reintroduce.

Prism general modifiers are abstract, empty, async, external, locked, unsafe, implements, and iterator.

Not all member types support all member modifiers. For example, member fields support only readonly and implements.

Syntax Example:
Cyborg = public class(System.Object)
public
  method Speak(pMessage: String); virtual;
end;
 
Series888 = public class(Cyborg)
public
  method Speak(pMessage: String); override;
end;

Complete Example

The following is a complete example using the class above. It assumes a form with a button on it.

namespace CR_MemberModifiers;

interface

uses
  System.Drawing,
  System.Collections,
  System.Collections.Generic,
  System.Linq,
  System.Windows.Forms,
  System.ComponentModel;

type
  /// <summary>
  /// Summary description for MainForm.
  /// </summary>
  MainForm = partial class(System.Windows.Forms.Form)
  private
    method button1_Click(sender: System.Object; e: System.EventArgs);
  protected
    method Dispose(disposing: Boolean); override;
  public
    constructor;
  end;

  Cyborg = public class(System.Object)
  public
    method Speak(pMessage: String); virtual;
  end;

  Series888 = public class(Cyborg)
  public
    method Speak(pMessage: String); override;
  end;

implementation

{$REGION Construction and Disposition}
constructor MainForm;
begin
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent();

  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

method MainForm.Dispose(disposing: Boolean);
begin
  if disposing then begin
    if assigned(components) then
      components.Dispose();

    //
    // TODO: Add custom disposition code here
    //
  end;
  inherited Dispose(disposing);
end;
{$ENDREGION}

method Cyborg.Speak(pMessage: String);
begin
  //Default cyborg voice.
  MessageBox.Show(pMessage);
end;

method Series888.Speak(pMessage: String);
begin
  //Series 800 sounding voice.
  MessageBox.Show(pMessage);
end;

method MainForm.button1_Click(sender: System.Object; e: System.EventArgs);
begin
  var Vick: Series888;

  Vick := New Series888;
  Vick.Speak("Hello, I am Vick.");
end;

end.

More Info


Comments

0 Comments.
Share a thought or comment...
 
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 = P1194A1
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 play-drums.com 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.

Intermediate

1 Intermediate Level Question

Question #1: True or False?

With regard to member modifiers, member fields support only readonly and implements. They do not support other member modifiers such as virtual, abstract, empty, etc.

Answer:
  • True
  • False

  •  KB Article #101735 Counter
    13980
    Since 12/22/2008
    Sales Website: www.prestwood.com Or visit our legacy sales site: 
    legacy.prestwood.com


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