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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:58:15+00:00 2026-06-13T05:58:15+00:00

I studied that during initialization of object, for example string s = Hello world;

  • 0

I studied that during initialization of object, for example

string s = "Hello world";

If RHS is implicitly convertible to LHS type object, then Copy Constructor would be called. But I have a friend who is pretty sure that constructor which takes char pointer as an argument would be called.But I told him that constructor with charpointer would be called only in cases as below

string s("Hello world");

Is that correct?

  • 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-13T05:58:16+00:00Added an answer on June 13, 2026 at 5:58 am

    Doing

    string s = "Hello world";
    

    is equivalent to

    string s( string( "Hello world" ) );
    

    so both the constructor taking char const* and the copy-constructor are called. However, the standard allows copy-elision where the copy-constructor call is elided (not done).

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

Sidebar

Related Questions

I studied that Java passes object references by value, and in order to make
Mat img=imread(image_location); I studied that 'img' variable is like an object reference variable in
I have studied that during a fork, the data and code segment of the
I have studied that Destructor is invoked whenever the object goes out of scope
I have studied that The inline specifier is a hint to the compiler that
We have studied the Variable Elimination recently and the teacher emphasizes that it is
I know this question will be closed because I studied many example of this
I studied polymorphism and understand that it can do dynamic method binding like below.
I studied the Twitter API Documentation today. Only find that we could use Twitter
I want to insert TAB characters inside a TEXTAREA, like this: <textarea>{KEYPRESS-INSERTS-TAB-HERE}Hello World</textarea> I

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.