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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:14:07+00:00 2026-05-11T11:14:07+00:00

Lets take an example in C# public class Foo { public Foo() { }

  • 0

Lets take an example in C#

public class Foo {     public Foo() { }     public Foo(int j) { } }  public class Bar : Foo {  } 

Now, All the public members of Foo is accessible in Bar except the constructor. I cannot do something like

Bar bb = new Bar(1); 

Why the constructors are not inheritable?

UPDATE

I do understand we can chain constructors, but I would like to know why the above construct is not valid. I am sure there should be a valid reason for it.

  • 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-11T11:14:08+00:00Added an answer on May 11, 2026 at 11:14 am

    Constructors are not inheritable because it might cause weird and unintended behavior. More specifically, if you added a new constructor to a base class, all derived classes get an instance of that constructor. That’s a bad thing in some cases, because maybe your base class specifies parameters that don’t make sense for your derived classes.

    A commonly given example for this is that in many languages, the base class for all objects (commonly called ‘Object’) has a constructor with no parameters. If constructors were inherited, this would mean that all objects have a parameterless constructor, and there’s no way to say ‘I want people who make an instance of this class to provide parameters X, Y and Z, otherwise their code shouldn’t compile.’ For many classes, it’s important that certain parameters be defined for their proper function, and making constructors non-heritable is part of the way that class authors can guarantee that some parameters are always defined.

    Edit to respond to comments: Ramesh points out that if constructors were inherited as he would like them to be, he could always override base class constructors using privately declared constructors in each derived class. That is certainly true, but there it a logistical problem with this strategy. It requires that writers of derived classes have to watch base classes closely and add a private constructor if they want block inheritance of the base class constructor. Not only is this a lot of work for people writing derived classes, this kind of implicit dependency across classes is exactly the sort of thing that can cause weird behavior.

    Ramesh – it’s not that what you describe would be impossible to add to a language. In general it’s not done because that sort of behavior could confuse people and lead to a lot of extra debugging and code writing.

    Quintin Robinson provides some very worthwhile responses to this question in the comments that are definitely worth reading.

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

Sidebar

Ask A Question

Stats

  • Questions 107k
  • Answers 107k
  • 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 Using XML trick, this should do it: SELECT i.ItemDescription, (SELECT… May 11, 2026 at 9:01 pm
  • Editorial Team
    Editorial Team added an answer Assuming "myJSONtext" is well formed JSON, you can get an… May 11, 2026 at 9:01 pm
  • Editorial Team
    Editorial Team added an answer Okay, after some more googling, I found that there is… May 11, 2026 at 9:01 pm

Related Questions

I'm working on an editor for files that are used by an important internal
My question is related to the command pattern, where we have the following abstraction
Recently I was talking to a co-worker about C++ and lamented that there was
EDIT: I suppose I should clarify, in case it matters. I am on a

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.