[Insight-developers] Run-time polymorphism and Insight
Bill Hoffman
bill.hoffman at kitware.com
Tue Jun 13 16:18:50 EDT 2000
Do a cvs update and you will get a new itkSmartPointer that will support
this. After the update the following should work:
itkObject::Pointer o = itkImage::New();
itkImage::Pointer i = dynamic_cast<itkObject*>(o);
We noticed the same problem here earlier this week, but did not check in
the fix. (the fix required providing a conversion operator
to a native pointer for the smartpointer class. We had removed it
to keep people from using native pointers, but the safety is not
worth the loss of polymorphism.)
At 04:11 PM 6/13/00 -0400, Josh Cates wrote:
>Hello developers,
>
>How do I up-cast or down-cast an Insight object? Since we are using
>smart pointers, I can't think of a way to use any of the conventional
>methods such as dynamic_cast.
>
>For example, say I want to treat an itkImage::Pointer as an
>itkObject::Pointer, etc,.
>
>In other words, how can I get polymorphic behavior from Insight objects?
>
>Thanks,
>
>Josh.
>
>+--+--+--+--+--+--+--+--+--+--+--+--
> Josh Cates
> Dept. of Electrical Engineering
> University of Tennessee, Knoxville
> Email: jecates at utk.edu
> Phone: (865) 974-0694
> URL: www.cs.utk.edu/~cates
>--+--+--+--+--+--+--+--+--+--+--+---
>
>
>_______________________________________________
>Insight-developers mailing list
>Insight-developers at public.kitware.com
>http://public.kitware.com/mailman/listinfo/insight-developers
More information about the Insight-developers
mailing list