• The compiler will generate assignment operators and copy constructors for you, if you don't define your own and certain other restrictions apply. So, you can define an arbitrary class and do a standard "temp swap" algorithm, without having to explicitly touch internal member variables with code: class A {   int x; }; A p, v, temp; // Swap: temp = p; p = v; v = temp;

Copyright 2020, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy