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 8209983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:55:18+00:00 2026-06-07T09:55:18+00:00

Suppose I want to override some class which is already defined somewhere, for example,

  • 0

Suppose I want to override some class which is already defined somewhere, for example, let’s say System.Classes.TOriginalClass, and I want to keep the original class name. I know I will have to define it something like this:

type
  TOriginalClass = class(System.Classes.TOriginalClass)
  ...
  end;

If I wanted to implement this custom overridden class within the same unit where it was declared, I don’t have any problem, so long as every place where I want it used is Below where I declared this class.

But suppose I want to use this replacement class in another unit. System.Classes is an extremely common unit, which is used in almost every other unit of mine. I would like to be able to use both the System.Classes unit as well as the unit where I have created this overridden version, let’s call it MyClasses.

I know that in any other unit, I could accomplish this by including the full unit/class in the declaration, like so:

type
  TMyClass = class(MyClasses.TOriginalClass)
  ...
  end;

But, that would pretty much defeat the whole purpose, because I would be forced to include MyClasses. as a prefix before the TOriginalClass. What I would like to do is not have to worry about where TOriginalClass was originally declared, and declare it like this…

type
  TMyClass = class(TOriginalClass)
  ...
  end;

…while being sure that TMyClass will be inherited from MyClasses.TOriginalClass instead of System.Classes.TOriginalClass.

I’m pretty sure this will consist of the order in which I declare each of these two units in the uses clause, for example, using System.Classes before using MyClasses. But is this supposed to be possible? What should I be aware of when doing this?

PS – TOriginalClass I know isn’t a real class, I’m using it to demonstrate any class which was originally declared in System.Classes. The same should apply for any original class in any unit.

  • 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-07T09:55:21+00:00Added an answer on June 7, 2026 at 9:55 am

    You already gave the answers.

    Yes, you can derive from MyClasses.TOriginalClass by only specifying TOriginalClass, but it requires that MyClasses comes later in the uses list than System.Classes, or that System.Classes is omitted from the uses list altogether. There is no other way, sorry.

    If you don’t qualify TOriginalClass, the compiler will use the “last” declaration it encountered. It will not automatically use the most derived one.

    Sorry.

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

Sidebar

Related Questions

Suppose I want to execute code, for example value += 5 inside a namespace
Suppose I want to make a Web application which uses a fixed width and
Suppose we want two constructors for a class representing complex numbers: Complex (double re,
Suppose I have some Message class like the following. (This is a made-up class
The scenario Suppose I have the following two model classes: public class ProductColor {
Suppose I have drawn simple text (say just the letter 'x') with some font
Suppose I want to create a service layer for my web application which uses
For example suppose I have a class Vehicle and I wish for a subclass
The title basically says it all. Suppose I have an element which I want
Suppose I have an ELF binary that's dynamic linked, and I want to override/redirect

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.