With assignment and copying you can implement an operator to handle those operations ina custom manner. Is it possible to do the same for casting of pointers? I know that in casting objects I can simply make a constructor that takes the Base type and it'll handle it, but what about pointers?
Code:
class A
{
virtual void foo() {}
};
class B : public A
{
};
int main()
{
A* a;
B* b;
//Is there a way to write a function in A that will be called when i do either of these?
b = ( B* ) a;
b = dynamic_cast<B*> a;
}