[Insight-users] C2440 when reinterpret_cast-ing from base to specific class
itkvtk123 at gmx.net
itkvtk123 at gmx.net
Wed Dec 16 15:10:05 EST 2009
Hello itk users!
Today I encountered a very simple problem but I could not find out what I'm doing wrong.
I want to convert a base class object to the specific class, but it does not seem to work.
I'm getting
"error C2440: 'reinterpret_cast' : cannot convert from 'itk::SingleValuedNonLinearOptimizer::Pointer' to 'itk::RegularStepGradientDescentOptimizer::Pointer"
Minimal Code:
///////////////////////////////////////////////////////////////////////////////////////////
#include "itkSingleValuedNonLinearOptimizer.h"
#include "itkRegularStepGradientDescentOptimizer.h"
int main()
{
typedef itk::SingleValuedNonLinearOptimizer OptimizerType;
typedef itk::RegularStepGradientDescentOptimizer GradientDescentType;
OptimizerType::Pointer optimizer = GradientDescentType::New();
reinterpret_cast<GradientDescentType::Pointer>(optimizer)->SetRelaxationFactor(0.5);
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////
Since RegularStepGradientDescentOptimizer is a child class from SingleValuedNonLinearOptimizer, I do not understand why this conversion does not work.
Any help appreciated!
--
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser
More information about the Insight-users
mailing list