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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:04:01+00:00 2026-06-17T21:04:01+00:00

I am implementing a new feature. I have a simple class with boolean variables.

  • 0

I am implementing a new feature.

I have a simple class with boolean variables.
I didn’t implement operator= function in it.
Still, When I copy objects using operator = the values are being copied.

Can you please explain how it is working?
How safe is it not to write this function, where as, in my application, many times, I’ll be copying these objects using operator ‘=’

#include <iostream>
using namespace std;
class A
{
    public:
    bool abc;
    bool xyz;
};
int main()
{
  A obj1, obj2;
  obj1.abc = true;
  obj1.xyz = false;

  obj2 = obj1;

  cout<<"obj2 abc: "<<obj2.abc<<endl; //How do the values got copied?
  cout<<"obj2 xyz: "<<obj2.xyz<<endl;

}
  • 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-17T21:04:03+00:00Added an answer on June 17, 2026 at 9:04 pm

    It’s safe if your class isn’t managing resources. The default operator = does a member-wise copy. This is a shallow copy, so all members that have an accessible operator = available will be correctly copied.

    The default is not safe if the class is managing resources (dynamic memory, streams, handles, etc.) – see the rule of three.

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

Sidebar

Related Questions

I'm implementing a new template for a Magento site. I have issues with categories
i'm trying to implement the example http://openlayers.org/dev/examples/drag-feature.html . When i'm implementing this with a
we have recently added a new feature to our software - preview generation for
I am implementing Google maps V3, I have a feature to search a location
A colleague of mine was implementing a new feature in a project we work
I'm implementing a small feature and kind of stuck. I have a button to
I am implementing a simple adder. However, I have a need for a bit
We are implementing a development flow where each new feature has its own branch,
Is there any good documentation on implementing new refactorings in Eclipse? Specifically, I'd like
I'm implementing a new iPhone app and am relatively new to Cocoa development overall.

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.