Link to home
Start Free TrialLog in
Avatar of chsalvia
chsalvia

asked on

Shallow copy with no assignment operator

Given a simple class like:

class Box {
    public:
    int a;
    int b;
};

int main() {
   Box b1;
   Box b2;
}

Are the following two statements effectively the same?  (i.e. do these statements generate the same exact machine code?)

b1 = b2;

memcpy(&b1, &b2, sizeof(Box));
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial