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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:01:22+00:00 2026-05-30T13:01:22+00:00

I have a set of classes where my base has a constructor that takes

  • 0

I have a set of classes where my base has a constructor that takes a configuration object and handles transferring the values to its properties.

abstract class A { public A(ObjType MyObj){} } 
abstract class B : A {}
class C : A {}
class D : B {}
class E : B {}

Is it possible to implicitly call a non-default base constructor from child classes or would I need to explicitly implement the signature up the chain to do it via constructors?

abstract class A { public A(ObjType MyObj){} } 
abstract class B : A { public A(ObjType MyObj) : base(MyObj){} }
class C : A { public A(ObjType MyObj) : base(MyObj){} }
class D : B { public A(ObjType MyObj) : base(MyObj){} }
class E : B { public A(ObjType MyObj) : base(MyObj){} }

If that is the case, is it better to just implement a method in the base then have my factory immediately call the method after creating the object?

  • 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-05-30T13:01:24+00:00Added an answer on May 30, 2026 at 1:01 pm

    Implicitly? No, constructors are not inherited. Your class may explicitly call it’s parent’s constructor. But if you want your class to have the same constructor signatures as the parent class’s, you must implement them.

    For example:

    public class A
    {
        public A(int someNumber)
        {
        }
    }
    
    // This will not compile becase A doesn't have a default constructor and B 
    // doesn't inherit A's constructors.
    public class B : A
    {
    }
    

    To make this work you’d have to explicitly declare the constructors you want B to have, and have them call A’s constructors explicitly (unless A has a default constructor of course).

    public class B : A
    {
        public B(int someNumber) : base(someNumber)
        {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a set of about two dozen classes that inherit from a base
I have a class called Prescriptions. It has properties that are other classes. So,
I have a abstract base class A and a set of 10 derived classes.
If have a set of classes that all implement an interface. interface IMyinterface<T> {
I'm using ASP.NET MVC RC2. I have a set of classes that were auto-generated
I have a set of callback classes that I use for handling callbacks with
I have written a set of classes and interfaces that are implemented in Moose
I have a set of core, complicated JavaScript data structures/classes that I'd like to
I have a multithreaded code that has to generated a set of objects and
Here are the classes as I have them set up: class Stat < ActiveRecord::Base

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.