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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:42:34+00:00 2026-06-06T07:42:34+00:00

When you define a class constructor in a base class (i.e. to set some

  • 0

When you define a class constructor in a base class (i.e. to set some static class variable), is it possible to override this class constructor in a derived class and call the constructor from its hierarchal parent with inherited?

Example:

TBaseclass = class(TObject)
public
   class constructor ClassCreate; virtual;
end;

TOtherClass = class(TBaseClass)
public
  class constructor ClassCreate; override;
end;

**implementation**

class constructor TBaseClass.ClassCreate;
begin
  //do some baseclass stuff
end;

class constructor TotherClass.ClassCreate;
begin
  inherited;
  //do some other stuff
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-06T07:42:36+00:00Added an answer on June 6, 2026 at 7:42 am

    There is no reason for class constructors to be virtual since they cannot be invoked polymorphically. You can’t call them directly; the compiler inserts calls to them automatically based on which classes are used in a program. Virtual methods are for run-time polymorphism, but since the compiler knows exactly which class constructors it’s invoking at compile time, there is no need for dynamic dispatch on class constructors or destructors.

    Virtual methods aren’t required for inheritance, however, so there should be no problem using inherited in a class constructor or class destructor. As David’s answer points out, though, the compiler ignores calls to inherited because it’s generally unwise to initialize a class multiple times, which is what you’d be doing if you really managed to call the inherited class constructor. If there’s something you need to happen twice, you’ll need to find a different way to make it happen.

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

Sidebar

Related Questions

I'd like to define an interface and abstract base class for a set of
I am trying to call a constructor of a Base Class in a function
I am using constructor chaining to define a base class (Super). function Super ()
Is it possible to write generic class with one constructor which explicitly defines type
I have made a Java class where I have defined a constructor and some
Now I research OOP-part of Scheme. I can define class in Scheme like this:
I want to define a class that is able to populate itself reading from
Suppose that I define some class: class Pixel { public: Pixel(){ x=0; y=0;}; int
I want to define a class method that has access to a local variable.
I have a common base class from which all my ASMX webservice classes will

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.