我有一个模板类中,称为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'
我能做些什么?
谢谢你,对我那可怜的英语感到抱歉。
我你已经把整个代码,这将是更好 –