I am new to templates and trying to implement Templates for creating ITK images:
template <class T,int D>
itk::Image< T, D>:: Pointer CreateITKImage(int *pnSize, double *pdSpacing = NULL)
{
typedef itk::Image< T, D> ImageType;
ImageType:: Pointer image = ImageType::New();
:
:
return image;
}
void main()
{
int Size[2] = {100,100};
itk::Image< int, 2>:: Pointer pImage;
pImage = CreateITKImage<int, 2>(Size);
}
Erors:
error C2146: syntax error : missing ';' before identifier 'CreateITKImage'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C3860: template argument list following class template name must list parameters in the order used in template parameter list
where as the the following code where i mention exclusively the type and dimension works fine.
template <class T,int D>
itk::Image< int, 2>:: Pointer CreateITKImage(int *pnSize, double *pdSpacing = NULL)
{
typedef itk::Image< T, D> ImageType;
ImageType:: Pointer image = ImageType::New();
:
:
return image;
}