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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:37:00+00:00 2026-05-25T01:37:00+00:00

I stumbled across a question that I never thought about before. Here it is:

  • 0

I stumbled across a question that I never thought about before.
Here it is:
each object’s (listed in the initialization list) “constructor” will be triggered.

class B
{
    public:
        B() { cout<<"B Con\n";}
        B(const B &b) { cout<<"B Copy Con\n";}
};

class A
{
    public:
        A(B &b):_m(b) { cout<<"A Con\n";}
        A(const A &a):_m(a._m) { cout<<"A Copy Con\n";}
    private:
        B _m;
}

main()
{
    B b;
    A a(b);
}

then I got the output as follows:

B Con
B Copy Con
A Con

According to the output, I think, ‘A a(b)’ triggered B’s copy constructor.
If I got right, then that means ‘A(B &b):_m(b)’ triggers B’s copy constructor.
Why not constructor but copy-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-05-25T01:37:01+00:00Added an answer on May 25, 2026 at 1:37 am

    The reason is when you call

    _m( whatever )
    

    then the copy constructor

    B(const B &b)
    

    is the only one that could match the parameter list. You pass it one parameter and that parameter is of type class B.

    Copy constructor is not something super special – it is just a parameterized constructor that will be invoked via the initialization list once the parameter list matches.

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

Sidebar

Related Questions

I stumbled across this youtube video here http://www.youtube.com/watch?v=Ha5LficiSJM that demonstrates someone doing color detection
I recently stumbled across this entry in the google testing blog about guidelines for
I've stumbled across this great post about validating parameters in C#, and now I
I just stumbled across this question and I noticed the user is using some
Recently I stumbled across this pretty slick JS library called nodeJS that acts like
If I'm not mistaken, I once stumbled across a product or something that let
I stumbled across this code and am too proud to go and ask the
I stumbled across my rather ancient photo objects disks, and sadly found out the
I just stumbled across this bug in some legacy code: class MyAPIHandler { private:
I'm trying out ASP.NET MVC routing and have of course stumbled across a problem.

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.