Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using typename

0 views
Skip to first unread message

mlt

unread,
Jun 29, 2009, 4:56:24 AM6/29/09
to
In a class MyReg I have the below constructor:

//template<typename T>
class MyReg{
public:
...
typedef itk::Image< PixelType, Dimension > FixedImageType;
typedef itk::Image< PixelType, Dimension > MovingImageType;
typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;
typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;

MyReg(MyParameters param, FixedImageReaderType::Pointer fixed,
MovingImageReaderType::Pointer moving){
this->param = param;
this->fixedImageReader = fixed;
this->movingImageReader = moving;
}

};

This compiles fine. But if I use the template declaration:

template<typename T>
class MyReg{
public:
...
...

I get the compiler error:

Error 2 error C2061: syntax error : identifier 'Pointer'

I have found that a fix is to add typename to the arguments in the
constructor:


MyReg(MyParameters param, typename FixedImageReaderType::Pointer fixed,
typename MovingImageReaderType::Pointer moving){


But why does this solve the problem? I have read that when typename is used
its to tell the compiler that follwing code is a type, but would that not be
obvious in a constructor?


Maxim Yegorushkin

unread,
Jun 29, 2009, 5:10:16 AM6/29/09
to
0 new messages