Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:04:38+00:00 2026-06-12T04:04:38+00:00

I have two Delphi classes. The parent class declares a string field FSSN and

  • 0

I have two Delphi classes. The parent class declares a string field FSSN and matching property SSN with accessors that read and write the field directly. In my child class I want to redeclare the property SSN to use a setter from the child class (to transform the SSN if possible before writing it to the field).

The property SSN will be set by a method of the parent class, but (if the instance is an instance of the child class) I want the child setter to be called. When I run the code, however, I never enter the child setter and the field appears to be set directly using the property declaration in the parent.

Can this be done?

(I realize I could accomplish this by introducing the setter procedure in the parent class and overriding in the child; I’d rather not disturb the parent class if possible).

Here’s what I have so far (in a drastically simplified version, of course):

TCustomPerson = class(TObject)
  protected
    FSSN: String;
  public
    procedure LoadFromXML(ANode: IXMLNode);
    property SSN: String read FSSN write FSSN;

TMyPerson = class(TCustomPerson)
  protected
    procedure SetSSN(ASSN: String);
  public
    property SSN: String read FSSN write SetSSN; // <=== Setter introduced.

 procedure TCustomPerson.LoadFromXML(ANode: IXMLNode);
 var ThisSSN: String;
 begin
    //extract SSN from XML into ThisSSN
    SSN := ThisSSN;                             // Expect to invoke SetSSN.
 end

procedure TMyPerson.SetSSN(ASSN: String);
begin
    FSSN := ValidateSSN(ASSN);                  // <== Breakpoint here never reached.
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:04:39+00:00Added an answer on June 12, 2026 at 4:04 am

    No; that’s not possible.

    The child class can access the parent class, but the parent has no knowledge of the child, and you don’t have anything in the parent class declared as virtual that you can use polymorphism to route.

    In the case of an overridden method, there’s a VMT that can be used to route to the proper dscendant class, but a straight property assignment without a setter can’t be virtualized. You need a setter in the parent that is declared as virtual, and then an override setter on the descendant will work. There’s no way to virtualize a straight variable assignment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes (MVC view model) which inherits from one abstract base class.
I have two string lists that I'm working with. One that has a list
I have two classes: one base class an one derived class The base class
Delphi part: I have a class with the event and from that event I
Have two folders with approx. 150 java property files. In a shell script, how
I have two queries that find both the Zip codes, and the States for
I have two different classes made in two different units, how do i will
I have two PCs both with XE2. I thought that I had installed identically
I have added these two methods to the 1st unit of my Delphi 5
I have a Delphi console application that at the end needs to launch one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.