I have been working on a project for a C++ course at Oregon Tech, and I have had trouble with an error that even my professor hasn't been able to help me with. I have been trying to use a move constructor, but I keep getting errors saying:
function "Shapes::operator=(const Shapes &)" (declared implicitly) cannot be referenced -- it is a deleted function - line 31
'Shapes::operator=(const Shapes &)': attempting to reference a deleted function - line 31
// Shapes.h
#ifndef LAB1_SHAPES_H
#define LAB1_SHAPES_H
class Shapes {
protected:
float m_width;
float m_area;
float m_perimeter;
public:
Shapes() {
m_width = 0;
m_area = m_width * m_width;
m_perimeter = 4 * m_width;
}
Shapes(float x) {
if (x > 0) {
m_width = x;
}
m_area = m_width * m_width;
m_perimeter = 4 * m_width;
}
Shapes(Shapes&& move) noexcept {
*this = move;
}
Shapes(const Shapes& copy) {
m_width = copy.m_width;
m_area = m_width * m_width;
m_perimeter = 4 * m_width;
}
float getWidth() const {
return m_width;
}
float getArea() const {
return m_area;
}
float getPerimeter() const {
return m_perimeter;
}
};
#endif //LAB1_SHAPES_H