Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/FFPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
3 changes: 3 additions & 0 deletions src/FFPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand Down
8 changes: 8 additions & 0 deletions src/FFVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
2 changes: 2 additions & 0 deletions src/FFVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand Down
Loading