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

  • SEARCH
  • Home
  • 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 153385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:47:30+00:00 2026-05-11T09:47:30+00:00

In one file, I have a baseclass with a ID-property: type TBase = class(TObject)

  • 0

In one file, I have a baseclass with a ID-property:

type   TBase = class(TObject)     private       FID: integer;     public       property ID: integer read FID write SetID;     end;   

In a second file, I have another class, descending from TBase. By accident, or ignorance or what ever, a new property/field with the same name as an exsisting property/field was made.

type   TSub = class(TBase)   private     FID: Longword;   public          property ID: Longword read FID write FID;   end; 

The second ID-fields is of course renamed, but why does the compiler allow this?
When accessing ID in code – which ID-field is used?

  • 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. 2026-05-11T09:47:30+00:00Added an answer on May 11, 2026 at 9:47 am

    Delphi allows this to ‘hide’ your old properties and introduce properties with the same name that operate differently. I’ve used this for example to create my own typesafe TList descendants for a specific class or record:

    type   TMyList = class(TList)   private     function GetItem(Index: Integer): TMyObject;     procedure SetItem(Index: Integer; Value: TMyObject);   public     property Items[Index: Integer]: TMyObject read GetItem write SetItem;   end;    function TMyList.GetItem(Index: Integer): TMyObject;   begin     Result := TMyObject(inherited Items[Index]);   end;    procedure SetItem(Index: Integer; Value: TMyObject);   begin     inherited Items[Index] := Value;   end; 

    Ofcourse, with Delphi 2009 and generics, it’s a lot easier now.

    Which ID you are accessing depends on the place you are calling ID from.

    procedure TSub.Foo; begin   ID := 5; //TSub.ID   inherited ID := 6 //TBase.ID end;  procedure TBase.FooBar; begin   ID := 5; //TBase.ID end;  var   Sub: TSub;   Base: TBase; begin   Sub := TSub.Create;   try     Sub.ID := 1; //assign 1 to TSub.ID     TBase(Sub).ID := 2; //assign 2 to TBase.ID     WriteLn(Sub.ID); //writes 1     WriteLn(TBase(Sub).ID); //writes 2     Base := Sub;     WriteLn(Base.ID); //writes 2   finally     Sub.Free;   end; end; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 93k
  • Answers 93k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you are processing the elements in the 'opposite… May 11, 2026 at 6:42 pm
  • Editorial Team
    Editorial Team added an answer Use OpenURI and open("http://...", :http_basic_authentication=>[user, password]) accessing sites/pages/resources that require… May 11, 2026 at 6:42 pm
  • Editorial Team
    Editorial Team added an answer No, actually, you must declare your con2 field static: private… May 11, 2026 at 6:42 pm

Related Questions

I asked a question about interfaces previously and got some excellent responses. I'm really
I'm trying to create a C++ class, with a templated superclass. The idea being,
I'm relatively new to NHibernate, but have been using it for the last few
For my current project I want to be able to load some classes from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.