Hi,
I have defined two constructors, one default and one with init parameters:
1 2
|
Complex();
Complex(double &x, double &iy) { m_x = x; m_iy = iy;}
|
Furthermore I have defined these operators:
1 2 3 4 5
|
Complex& operator=(Complex& other);
Complex& operator=(Complex&& other);
Complex& operator=(const Complex& other);
Complex& operator=(const Complex&& other);
Complex& operator=(const Complex other);
|
But when I use the second constructor, as in here
This is marked as "error: use of deleted function 'constexpr Complex::Complex(const Complex&)'
Complex Complex::squared(Complex &c) {return c.squared(); }"
I have tried to define
1 2 3 4 5
|
constexpr Complex& operator=(const Complex &other) const {
m_x = other.x();
m_iy = other.iy();
return *this;
}
|
But this causes the following errors:
1st line: "no return statement in constexpr function"
2nd/3rd line: "cannot assign to non-static data member within const member function 'operator='"
4th line: "binding value of type 'const Complex' to reference to type 'Complex' drops 'const' qualifier"
I obviously haven't sufficiently understood the concept of contexpr (and others).
Any idea how to satisfy the compiler?
^