N
NKOBAYE027
I want to use the * operator of the parent class in the def'n of the *
operator for my child class. Is there an elegant way to do this e.g.
template<typename object>
class foo : public pFoo<object>
{
// yadayadayada
object& operator*()
{
WhateverDereferencedParentReturns bar =
HowDoIGetTheReturnOfParentOperator*;
return SomeOperation(bar);
}
}
I think I can do a static_cast on the 'this' pointer to get 'bar'
e.g.
WhateverDereferencedParentReturns bar = *static_cast<pFoo>(*this);
but this seems clunky to me...is there a more elegant solution?
regards,
L.
operator for my child class. Is there an elegant way to do this e.g.
template<typename object>
class foo : public pFoo<object>
{
// yadayadayada
object& operator*()
{
WhateverDereferencedParentReturns bar =
HowDoIGetTheReturnOfParentOperator*;
return SomeOperation(bar);
}
}
I think I can do a static_cast on the 'this' pointer to get 'bar'
e.g.
WhateverDereferencedParentReturns bar = *static_cast<pFoo>(*this);
but this seems clunky to me...is there a more elegant solution?
regards,
L.