我有一個模板類中,稱爲Cell
,這裏的定義:調用模板基類的轉換運算符的派生類
template <class T>
class OneCell
{
.....
}
我有一個轉換運算符從Cell
到T,這裏
virtual operator const T() const
{
.....
}
我現在已經派生類,叫做DCell
,這裏
template <class T>
class DCell : public Cell<T>
{
.....
}
我需要重寫Cell的轉換運算符(插入一點if),但需要調用Cell的轉換運算符後。在其他的方法它應該像
virtual operator const T() const
{
if (...)
{
return Cell<T>::operator const T;
}
else throw ...
}
,但我得到一個編譯器錯誤
error: argument of type 'const int (Cell::)()const' does not match 'const int'
我能做些什麼?
謝謝你,對我那可憐的英語感到抱歉。
我你已經把整個代碼,這將是更好 –