2016-11-28 253 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是不相關的類型。