1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Point::Point(float px, float py)
: x(priv_x), y(priv_y), priv_x(px), priv_y(py)
{
}
//Constructeur de copie:
//on n'essaie pas de copier les références,
//on les assigne à nos propres membres.
Point::Point(Point const &src)
: x(priv_x), y(priv_y), priv_x(src.priv_x), priv_y(src.priv_y)
{
}
Point& Point::operator= (Point const &src)
{
Point tmp(src);
Swap(tmp);
}
//On n'essaie pas de swapper les références,
//seulement les variables internes (non-const)
void Point::Swap(Point& other)
{
std::swap(priv_x, other.priv_x);
std::swap(priv_y, other.priv_y);
} |