Codey McCodeface Codey McCodeface - 1 year ago 74
C++ Question

C++ abstract type declaration

I am using ITK.

is a subclass of

Why is the statment below not valid?

itk::InterpolateImageFunction<ImageType,double>::Pointer interpolator = itk::LinearInterpolateImageFunction<ImageType, double>::New();

The error I get is

error: conversion from
itk::LinearInterpolateImageFunction<itk::Image<unsigned char, 3u>,
double>::Pointer {aka
char, 3u>, double> >}
to non-scalar type
itk::InterpolateImageFunction<itk::Image<unsigned char, 3u>,
double>::Pointer {aka
char, 3u>, double> >}

Answer Source

The InterpolateImageFunction::Pointer typedef is to SmartPointer<InterpolateImageFunction>. Unlike std::shared_ptr, itk::SmartPointer does not support conversions between smart pointers of related types. That is, InterpolateImageFunction<X,Y>::Pointer and LinearInterpolateImageFunction<X,Y>::Pointer are unrelated types.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download