diff --git a/src/FFPoint.cpp b/src/FFPoint.cpp index 0d21c84..a7a8cc7 100644 --- a/src/FFPoint.cpp +++ b/src/FFPoint.cpp @@ -32,6 +32,16 @@ FFPoint::~FFPoint(){ FFPoint::FFPoint(const FFPoint& p) : x(p.x), y(p.y), z(p.z) { // nothing else to do } +// Spelled out rather than left implicit: declaring the copy-constructor above +// deprecates the implicit assignment, so every `a = b` on an FFPoint raises +// -Wdeprecated-copy. The three coordinates own no memory, so copying them is +// exactly what the implicit version did. +FFPoint& FFPoint::operator=(const FFPoint& p){ + x = p.x; + y = p.y; + z = p.z; + return *this; +} // overloading operators const FFPoint operator+(const FFPoint& left, const FFPoint& right){ diff --git a/src/FFPoint.h b/src/FFPoint.h index bb3eb67..10bb8e0 100644 --- a/src/FFPoint.h +++ b/src/FFPoint.h @@ -40,6 +40,9 @@ class FFPoint { /*! \brief Copy-constructor * \param[in] 'p' : point to be copied */ FFPoint(const FFPoint& p); + /*! \brief Copy-assignment + * \param[in] 'p' : point to be copied */ + FFPoint& operator=(const FFPoint& p); /*! \brief overloaded operator + */ friend const FFPoint operator+(const FFPoint&, const FFPoint&); diff --git a/src/FFVector.cpp b/src/FFVector.cpp index cf50fbc..abe772e 100644 --- a/src/FFVector.cpp +++ b/src/FFVector.cpp @@ -44,6 +44,14 @@ FFVector::~FFVector() { FFVector::FFVector(const FFVector& v) : vx(v.vx), vy(v.vy), vz(v.vz){ // nothing else to do } +// Same reason as FFPoint::operator=: the copy-constructor above deprecates the +// implicit assignment, and the three components own no memory. +FFVector& FFVector::operator=(const FFVector& v){ + vx = v.vx; + vy = v.vy; + vz = v.vz; + return *this; +} // overloading operators const FFVector operator+(const FFVector& left, const FFVector& right){ diff --git a/src/FFVector.h b/src/FFVector.h index 7e91e29..a1301a2 100644 --- a/src/FFVector.h +++ b/src/FFVector.h @@ -41,6 +41,8 @@ class FFVector { virtual ~FFVector(); /*! \brief Copy-constructor */ FFVector(const FFVector&); + /*! \brief Copy-assignment */ + FFVector& operator=(const FFVector&); /*! \brief overloaded operator + */ friend const FFVector operator+(const FFVector&, const FFVector&);