The assignment operator copies one object to another member-wise. If you do not overload the assignment operator, it performs the bitwise copy. When the bitwise assignment is performed both the object shares the same memory location and changes in one object reflect in another object. This concept and my code goes contrary. Can someone please explain me why..
#include<bits/stdc++.h>
using namespace std;
class A
{
public:
int x;
};
int main()
{
A a1,a2;
a1.x=5;
a2.x=5;
a2=a1;
a1.x=10;
cout<<a1.x<<" "<<a2.x;
return 0;
}