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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:27:05+00:00 2026-06-10T06:27:05+00:00

Theoretical doubt here. Reading a book, and given this statement: StringBad metoo = knot;

  • 0

Theoretical doubt here. Reading a book, and given this statement: StringBad metoo = knot; where:

  • StringBad is a class
  • knot is an object of that class

the author says the following regarding copy constructors:

implementations have the option of handling this statement in two
steps: using the copy constructor to create a temporary object and
then using assignment to copy the values to the new object.That is,
initialization always invokes a copy constructor, and forms using the
= operator may also invoke an assignment operator.

My implementation do this in one step:

  • Creates the metoo object with the copy constructor, the same as this : StringBad metoo(knot);

I could understand that other implementations could do it in two steps like this:

  • Create a metoo object with the default constructor, like : StringBad metoo;
  • Use the overloaded asignment operator to assign the knot object to the metoo object.

But the author says an initialization always invokes a copy constructor. Is that correct? If so, what are the steps the compiler would follow in some implementations to make it in two steps? I couldn’t test it in mine cause, as I said it does it in one step.

  • 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-10T06:27:06+00:00Added an answer on June 10, 2026 at 6:27 am

    The author is wrong. What you have is a declaration statement with copy initialization, and the only way this can be realized is by instantiating a new object via the StringBad(StringBad const &) copy constructor.* The assignment operator will never be called in this situation, and doesn’t even need to exist or be accessible.

    There is almost no difference between the two variants StringBad metoo = knot; and StringBad metoo(knot);.

    *) or the non-const version if that happens to exist and match.

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

Sidebar

Related Questions

This is a theoretical question, so expect that many details here are not computable
This is a purely theoretical question. Given three simple classes: class Base { }
This is more a theoretical question than a practical one, but given I undestand
I have a theoretical grid of overlapping rectangles that might look something like this:
This is purely a theoretical question, I know that if someone declares a method
a theoretical question. After reading Armstrongs 'programming erlang' book I was wondering the following:
Theoretical question here: How do people feel about the restrictions that registration forms have
This is a purely theoretical question, I know that the standard containers interface are
This is a purely theoretical 'what if' question, so no pressure to rush to
Consider a theoretical factory class containing over a thousand of attributes (models, by example,

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.