Item 12. Assignment and Initialization Are Different

Initialization and assignment are different operations, with different uses and different implementations.

Let’s get it absolutely straight. Assignment occurs when you assign. All the other copying you run into is initialization, including initialization in a declaration, function return, argument passing, and catching exceptions.

Assignment and initialization are essentially different operations not only because they’re used in different contexts but also because they do different things. This difference in operation is not so obvious in the built-in types such as int or double, because, in that case, both assignment and initialization consist simply of copying some bits (but see also

Get C++ Common Knowledge: Essential Intermediate Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.