FairyA 0 Newbie Poster

I have search though multiple similar topics but still can't find the answere. Would you please help ?

The error is :

invalid initialization of reference of type 'ArrayT<float>&' from expression of type 'const Arrat<float>'

The above errors occur when I tried to do the following code , with operator* overloading :

const ArrayT<float>& b1 = A*A;
ArrayT<float>& c2 = b1*A;// <---- this line makes the error
//when doing it without the & i.e ArrayT<float> c2 = b1*A , it runs fine

//b1 is a const ref of ArrayT<float>
//A is just a normal object of ArrayT<float> created by ArrayT<float> A(blah,blah,blah);

The following are the list of operator* overloading :

template <class T>
ArrayT<T>& ArrayT<T>::operator*(ArrayT<T>& b) {blah,blah,blah}  

template <class T>
const ArrayT<T>& ArrayT<T>::operator*(ArrayT<T>& b) const

template <class T>
const ArrayT<T>& ArrayT<T>::operator*(const ArrayT<T>& b) const

template <class T>
ArrayT<T>& ArrayT<T>::operator*(const ArrayT<T>& b)  

template <class S>
ArrayT<S>& operator*(const ArrayT<S>& a,ArrayT<S>& b) //(***)
// <--------This (***) one I want to use for error multiplication above, but not success.

Basically here is what I need to do, I have success for most of them except the above.

const ArrayT<float>& b1 = A*A;
const ArrayT<float>& b2 = b1*A;
const ArrayT<float>& b3 = A*b1;
ArrayT<float>& c1 = A*A

;
ArrayT<float>& c2 = b1*A;// <-------- Trouble here


ArrayT<float>& c3 = A*b1;
const ArrayT<float> d1 = 2.*A*A;
const ArrayT<float> d2 = 3.*b1*A;
const ArrayT<float> d3 = A*b1;
const ArrayT<float>& e1 = 3.f*d1*A*b1;
const ArrayT<float>& e2 = 2.f*c1*A*b1;
const ArrayT<float>& e3 = A*c1*b1;
const ArrayT<float>& f1 = d1*A*b1;
const ArrayT<float>& c4 = d1*A*b1;
const ArrayT<float>& c5 = A*d1*b1;
const ArrayT<float>& f1 = d1*A + b1*b3*e2 + 3.*c4;
const ArrayT<float>& f2 = 2.*A*A;