当类对象能按照BITWISE COPY,使用memset或者memcpy函数~~~
例如
class Point3d {
public:
Point3d( float x, float y, float z );
// ...
private:
float _x, _y, _z;
};
Point3d::Point3d( const Point3d &rhs )
{
_x = rhs._x;
_y = rhs._y;
_z = rhs._z;
};
和
Point3d::Point3d( const Point3d &rhs )
{
memcpy( this, &rhs, sizeof( Point3d );
};
后者的效率高于前者。