Hidden Casting

Hey guys,

I’m typing up a C++ wrapper of SDL_mixer and I was considering a
particular, not altogether necessary, feature. Is there anything
wrong with using virtual functions to hide dynamic casts? Something
like this:
class Base
{
public:
virtual A* getA()
{
return NULL;
}
virtual B* getB()
{
return NULL;
}
};

class A : public Base
{
virtual A* getA()
{
return this;
}
};

class B : public Base
{
virtual B* getB()
{
return this;
}
};

There’s not much of a benefit, except that I type:
C* c = new A;
A* a = c->getA();

rather than:
C* c = new A;
A* a = dynamic_cast<A*>©;

Okay. If that’s the only difference, then it’s probably overkill, but
I could also add Base::isA() and Base::isB(), which inverts the
dynamic_cast testing:
if(c->isA())
{
A* a = c->getA();
// do stuff
}

instead of:
A* a = dynamic_cast<A*>©;
if(a != NULL)
{
// do stuff
}

This seems to make it easier and more intuitive to check for common
functionality and such:
if(c->isA() || c->isD())
{
// do stuff that B can’t do
}

Is there any problem with this? Is it worth it (keep in mind that it
is easy to do)? It’s probably not that slow, right? I guess I could
even just hide a dynamic_cast in Base, instead of using virtual
functions…

Jonny D