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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:34:40+00:00 2026-06-01T08:34:40+00:00

basic c++ question i’m fairly sure. if i have a base class with a

  • 0

basic c++ question i’m fairly sure. if i have a base class with a constructor that takes no parameters, and just initializes some of the protected members, does a derived class instantly call this base constructor too if it matches the parameters (wishful but unlikely thinking), and if not, is there a way to force it to automatically call said base constructor from the derived class WITHOUT having to explicitly tell it to do so in the derived class? I ask because i’m writing a wrapper of sorts and there are some protected members that i want initialized to specific values initially, and then i want to derive and manipulate this base class to my needs, but i wouldn’t like an outside user to have to remember to explicitly call the base constructor or set these values within their own constructor.

  • 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-01T08:34:42+00:00Added an answer on June 1, 2026 at 8:34 am

    Yes, the default base constructor is always called unless explicitly stated otherwise.

    For example:

    class A
    {
    public:
       A() { std::cout << "A"; }
    };
    
    class B : A
    {
    public:
       B() {}
    };
    
    int main()
    {
       B b;
       return 0;
    }
    

    will output:

    A
    

    By “explicitly stated otherwise” I mean that you can call a different constructor from the derived class:

    class A
    {
    public:
       A() { std::cout << "A"; }
       A(int) { std::cout << "AAA"; }
    };
    
    class B : A
    {
    public:
       B() : A(1) {}  //call A(int)
    };
    
    int main()
    {
       B b;
       return 0;
    }
    

    will output

    AAA
    

    Important if you don’t have a default constructor (you declare a non-default constructor and not a default one) or the default constructor is not visible (marked as private), you need to explicitly call an available constructor in the derived class.

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

Sidebar

Related Questions

Really basic question I'm sure for some of you Java heads out there. I
really basic question, I have a string to generate as SQL statement that I
I have a basic question that I can't seem to resolve using Google (Or
Basic question; I have this code: var partipiansRow = '<div class=form-row ><input type=text id=name
Basic question. char new_str[]=; char * newstr; If I have to concatenate some data
I have a basic question on destructors. Suppose I have the following class class
Pretty basic question: I have a model x that has_many y, and model y
Basic question - I have a text area with a submit button that is
Very basic question I think. I have a website where some pages are likely
Basic question! I have 2 tables PRODUCE +-----+--------------+ | id | fruit_name | +--------------------+

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.