Edit - Put the question into context a bit 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)) { }
it does not work. a const_cast
doesn't make sense to me as I don't want to change the constness, and I'm not changing what I'm pointing to, so why then does g++ tell me
invalid static_cast from type ‘Derived* const’ to type ‘Base* const’
? If I leave out the cast, it says
no matching function for call to ‘Alice::Alice(Derived* const)’
If anyone could shed any light on this It'd be much appreciated.