2016-11-28 162 views
0

我正在使用ITK。 itk::LinearInterpolateImageFunctionitk::InterpolateImageFunction的一个子类。C++抽象类型声明

为什么下面的表述无效?

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

我得到的错误是

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

回答

4

InterpolateImageFunction::Pointer的typedef是SmartPointer<InterpolateImageFunction>。与std::shared_ptr不同,itk::SmartPointer不支持相关类型的智能指针之间的转换。也就是说,InterpolateImageFunction<X,Y>::PointerLinearInterpolateImageFunction<X,Y>::Pointer是不相关的类型。