Change Put the question in context a little more.
Given:
struct Base
{
...
};
struct Derived : public Base
{
...
};
class Alice
{
Alice(Base *const _a);
...
};
class Bob : public Alice
{
Bob(Derived *const _a);
...
};
When I try to implement
Bob::Bob(Derived *const _d) : Alice(static_cast<Base*const>(_d)) { }
he does not work. a const_castdoesn't make sense to me, because I don't want to change the constant, and I don't change what I'm pointing to, so why does g ++ tell me
invalid static_cast from type ‘Derived* const’ to type ‘Base* const’
? If I refuse the cast, he will say
no matching function for call to ‘Alice::Alice(Derived* const)’
If anyone could shed light on this, it would be very grateful.
source
share