- C++相談室 part116 [転載禁止]©2ch.net
300 :デフォルトの名無しさん[sage]:2015/03/24(火) 23:23:37.91 ID:31iHMNlf - template<typename T> struct C1 {
T x,y,z; void swap(T&r){std::swap(x,r.x);std::swap(y,r.y);std::swap(z,r.z);} C1(const C1&r):x(r.x),y(r.y),z(r.z){} C1&operator=(const C1&r){C1 tmp(r);swap(tmp);return*this;} }; template<typename T> struct C2 { // 手抜き T x,y,z; C2(const C2&r){*this=r;} C2&operator=(const C2&r){x=r.x;y=r.y;z=r.z;return*this;} };
|
|