C++ operator question.

From: KOSU_FOKIN@garbo.lucas.lu.se
Date: Sun Oct 31 1999 - 16:37:14 MET


Hello rooters!          

Is it possible to redefine operator[] in TObjArray
so that it returns my own type? Something like

class THistoricalData : public TObjArray {
public:
                             THistoricalData::THistoricalData();
   virtual THistoricalData*& operator[](Int_t i);
};

inline THistoricalDataObj *&THistoricalData::operator[](Int_t at)
{
   return (THistoricalDataObj*)[at];
}


Of course it gives

"THistoricalData.h", line 16: Error: Virtual function THistoricalData::operator[](int) returns THistoricalData*&, while TObjArray::operator[](int) returns TObject*&.
"THistoricalData.h", line 20: Error: THistoricalData::operator[](int), returning THistoricalDataObj*&, was previously declared returning THistoricalData*&.

Is there any way around to solve it?

Best regards,
Anton



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:41 MET