Call the cast operator of template base class within the derived class
Posted
by
yoni
on Stack Overflow
See other posts from Stack Overflow
or by yoni
Published on 2012-06-19T21:14:45Z
Indexed on
2012/06/19
21:15 UTC
Read the original article
Hit count: 357
I have a template class, called Cell
, here the definition:
template <class T>
class OneCell
{
.....
}
I have a cast operator from Cell
to T, here
virtual operator const T() const
{
.....
}
Now i have derived class, called DCell
, here
template <class T>
class DCell : public Cell<T>
{
.....
}
I need to override the Cell's cast operator (insert a little if), but after I need to call the Cell's cast operator. In other methods it's should be something like
virtual operator const T() const
{
if (...)
{
return Cell<T>::operator const T;
}
else throw ...
}
but i got a compiler error
error: argument of type 'const int (Cell::)()const' does not match 'const int'
What can I do?
Thank you, and sorry about my poor English.
© Stack Overflow or respective owner