Error C2100 - Illegal Indirection

arrays, c++, compiler-errors, templates

Solution

Don't forget your operator precedence rules. It seems that you want:

(*TempArray2)[i]

Otherwise your expression `*TempArray2[i]` is considered as `*(TempArray2[i])` and I suppose your `NumericArray<T>` type doesn't have the unary `*` operator overloaded.

Problem

I have a very simple program written to define a * operator in an array template class. When I try to compile it gives me an error "illegal indirection". Any help on the matter would be greatly appreciated! This is the operator definition: ``` template <typename T> NumericArray<T> NumericArray<T>::operator * (const int factor) const { NumericArray<T>* TempArray2 = new NumericArray<T>(Size()); for (int i=0; i<Size(); i++) { *TempArray2[i] = ((GetElement(i))*(factor)); } return *TempArray2; } ``` And this is the implementation in the test main function: ``` cout<<((*intArray1)*5).GetElement(0); cout<<((*intArray1)*5).GetElement(1); cout<<((*intArray1)*5).GetElement(2); ``` Any ideas?

Original source