C++ Language/Objects/Constructors/InitializationByCopyConstructor

From Wikibooks, open books for an open world
Jump to navigation Jump to search

"Implicit initialization" (CRType oImp = oCopied;) and "explicit initialization" (CRType oExp(oCopied);) are equivalent in the sense that they both invoke CRType's "copy-constructor". The copy-constructor's signature is CRType::CRType(const CRType& aroCopied). This same copy-constructor will also be called whenever an object is passed-by-value into some function.

Additional information about copy-constructors (includes interactive examples)