I'm learn C++ (overloading operators if be precise). I try overload operator+ by this way:
Complex4d Complex4d::operator+(const Complex4d &rvalue)
{
return Complex4d(a() + rvalue.a(), b());
}
Where rvalue.a() and a(), rvalue.b() and b() it's object of the Complex2d. In Complex2d class I overload operator+ too, by this way:
Complex2d Complex2d::operator +(Complex2d &rvalue)
{
return Complex2d(a() + rvalue.a(), b() + rvalue.b());
}
If I write this:
Complex4d Complex4d::operator+(const Complex4d &rvalue)
{
Complex2d test = rvalue.a();
return Complex4d(a() + test, b());
}
All it's OK. What do i do wrong?