copy constructor
任意のクラスインスタンスは必ずcopy constructorを持っている。copy constructorには2種類ある:
- implicit copy constructor
- user-defined copy constructor
intはオブジェクトである。
user-defined copy constructorがあるときには、rule of fiveの原則により、他のメンバ関数も定義されなければならない。
copy constructorのシグネチャは、T (const T& Object);
である。
copy constructorというものとassignment operatorというものがあって、同じ「=」を書いて操作するので、少し紛らわしい。未初期化のオブジェクトに対する構文ではcopy constructorが使われ、初期化済みのオブジェクトに対する構文ではassignment operatorが使われる。