Solution to the Virtual Class Inheritance cast

Categories: Technology
Comments: Comments Off on Solution to the Virtual Class Inheritance cast
Published on: February 2, 2006

In my last post, I talked about using Virtual Class Inheritance, and was thinking about how to cast it.

well I have come up with from books and talking with others to try this:
[code]
// See http://blog.mikeoconnor.net/?postid=874
// for the class defs

grandchild* Base2grandchild(Base *ptr)
{
grandchild *toBeReturned;
try
{
toBeReturned = dynamic_cast(ptr);
return toBeReturned;
}
catch(…)
{
// cast failed deal with it
}
return NULL;
}
[/code]
So it looks like what needs to be done.

Welcome , today is Thursday, December 26, 2024