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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:05:05+00:00 2026-06-03T04:05:05+00:00

Possible Duplicate: How are C array members handled in copy control functions? If I

  • 0

Possible Duplicate:
How are C array members handled in copy control functions?

If I don’t override the operator = of a class, it will use default memberwise assignment.

But what does it mean?

struct A {
    int array[100];
};
A a;
A b=a;

No error. How does b copes a‘sarray? Normally array_b = array_a is invalid.

Another exampe:

struct A {
    vector<int> vec;
};
A a;
A b=a;

How does b copes a‘svec? Through assignment(vec_b = vec_a), constructor(vec_b = vector<int>(vec_a)) or other mystery way?

  • 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-03T04:05:07+00:00Added an answer on June 3, 2026 at 4:05 am
    A b=a;
    

    Is not assignment, it is called as Copy Initialization.

    The implicitly generated copy constructor is called to create an new object b from the existing object a.
    The implicitly generated copy constructor makes a copy of the array member.

    For completeness I am going to add here the standard citation from the marked duplicate.

    C++03 Standard: 12.8 (Copying class objects)

    Each subobject is copied in the manner appropriate to its type:

    • if the subobject is of class type, the copy constructor for the class is used;
    • if the subobject is an array, each element is copied, in the manner appropriate to the element type;
    • if the subobject is of scalar type, the built-in assignment operator is used.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How are C array members handled in copy control functions? I would
Possible Duplicate: How to sum array members in Ruby? Lets say I have this
Possible Duplicate: Array versus List<T>: When to use which? Is there any best practice
Possible Duplicate: initialize a const array in a class initializer in C++ If I
Possible Duplicate: Intitialzing an array in a C++ class and modifiable lvalue problem As
Possible Duplicate: Java Generics: Array containing generics I have a Java class which contains
Possible Duplicate: Copying array by value in javascript How to copy an array of
Possible Duplicate: Array slicing in Ruby: looking for explanation for illogical behaviour (taken from
Possible Duplicate: byte[] array pattern search I am trying to write a simple compression
Possible Duplicate: php multi-dimensional array remove duplicate I have an array like this: $a

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.