Exercise: Copy-and-Swap Idiom

Test your understanding of the copy-and-swap idiom.

Problem statement

Make two objects of the Foo class and swap them by writing the swap method for the Foo class.

Expected output

You can show the swapped names of the two objects using the print function given in the Foo class.

Coding challenge

Get hands-on with 1200+ tech skills courses.