[Insight-users] One of the common Errors-want to know why it occurs

David Doria daviddoria at gmail.com
Mon Sep 3 08:30:25 EDT 2012


On Mon, Sep 3, 2012 at 8:28 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> SetInput requires a const.
>
> Either:
>
> const  itk::Image<InputPixelType, Dimension>* pOutputImage =
> reader1->GetOutput();
>
>   CCFilter->SetInput(pOutputImage);
>
> or
>
>   CCFilter->SetInput(reader1->GetOutput());

Can't you usually pass a non-const pointer to a function that accepts
a const pointer though?

This compiles fine for me:

#include "itkImage.h"

typedef itk::Image<unsigned char, 2> ImageType;

static void MyFunction(const ImageType* image){}

int main(int, char* [] )
{
  ImageType::Pointer imageSmartPointer = ImageType::New();
  ImageType* image = imageSmartPointer.GetPointer();
  MyFunction(image);

  return 0;
}

David


More information about the Insight-users mailing list