Return type defined in header file

Hello,
I have a question about defining return types in the header file. I'm using the ITK toolkit and define a return type in my header, but when I compile the code the compiler returns an error that I have not defined the type. My code looks something like below and when I compile it I get the error Registrations.cpp:3: error: ‘VectrImageType’ has not been declared . If I re-type the typedefs in the cpp file it compiles fine, but I thought that the header file would create the types and pass them to the cpp file when I #include it. Why do I need to retype the typedefs?

I have taught myself c++ over the last few months coming from a matlab background, so general comments are also welcome...

Registrations.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef REGISTRATIONS_H_
#define REGISTRATIONS_H_

#include <iostream>
#include <limits>
#include <itkVector.h>
#include <itkImage.h>
#include <itkTranslationTransform.h>
#include <itkAffineTransform.h>
#include <itkLinearInterpolateImageFunction.h>
#include <itkBSplineInterpolateImageFunction.h>
#include <itkRegularStepGradientDescentOptimizer.h>
#include <itkLBFGSOptimizer.h>
#include <itkMeanSquaresImageToImageMetric.h>
#include <itkImageRegistrationMethod.h>

class Registrations {
	
	public:
        typedef short	ImagePixelType;
	typedef double 	VectrComponentType;
	typedef itk::Vector< VectrComponentType, 4 > VectrPixelType;
	typedef itk::Image< ImagePixelType, 3 >	FixedImageType;
	typedef itk::Image< ImagePixelType, 3 >	MovingImageType;
	typedef itk::Image< ImagePixelType, 3 >	SegmentImageType;
	typedef itk::Image< VectrPixelType, 3 >	VectrImageType;
	typedef itk::Image< VectrComponentType, 3 > VectrComponentImageType;

	VectrImageType::PixelType GlobalRegistration(FixedImageType::Pointer fImage,MovingImageType::Pointer mImage,unsigned int numberOfThreads);
		
	VectrImageType::PixelType DVCRegistrationLinear(FixedImageType::Pointer fImage,MovingImageType::Pointer mImage,VectrPixelType initializationData,unsigned int numberOfThreads);
		
};

#endif /*REGISTRATIONS_H_*/  


Registrations.cpp
1
2
3
4
5
6
7
8
9
10
#include "Registrations.h"

VectrImageType::PixelType Registrations::GlobalRegistration( FixedImageType::Pointer fImage, MovingImageType::Pointer mImage, unsigned int numberOfThreads)
{
  /* A whole bunch of code to do my bidding*/
}
VectrImageType::PixelType Registrations::DVCRegistrationLinear( FixedImageType::Pointer fImage, MovingImageType::Pointer mImage, VectrPixelType initializationData,unsigned int numberOfThreads)
{
  /* More code to make the computer my slave*/
}



You didn't define VectrImageType in the global namespace.

This should work:

1
2
3
4
5
6
7
8
9
10
#include "Registrations.h"

Registrations::VectrImageType::PixelType Registrations::GlobalRegistration( FixedImageType::Pointer fImage, MovingImageType::Pointer mImage, unsigned int numberOfThreads)
{
  /* A whole bunch of code to do my bidding*/
}
Registrations::VectrImageType::PixelType Registrations::DVCRegistrationLinear( FixedImageType::Pointer fImage, MovingImageType::Pointer mImage, VectrPixelType initializationData,unsigned int numberOfThreads)
{
  /* More code to make the computer my slave*/
}


Thanks PanGalactic, that worked. Your help is much appreciated!
Topic archived. No new replies allowed.