M
Matthias Spiller
Hi,
following problem. I'm writing an Image class and want to use templates:
....
template<class TType, int TLayers>
class Image
{
public:
Image();
Image(std::string filename);
....
Where TType stands for int, char aso and TLayers for Grey, RGB aso.
Now, converting Images from one type to another should be possible by
using the copy constructor:
Image<short, RGB> i("blub.jpg");
Image<double, Grey> j(i);
So, I'm trying to declare the copy contructor as follows:
template<class UType, int ULayers>
Image(const Image<UType, ULayers> &img);
and implement it:
template<class UType, int ULayers>
Image<unsigned char, Grey>::Image(const Image<UType, Ulayers> &img)
{
...
};
But at compile time I get the following error:
error: no `Image<unsigned char, 1>::Image(const Image<UType, ULayers>&)'
member function declared in class `Image<unsigned char, 1>'
error: invalid function declaration
Any ideas?
Cheers
matspi
following problem. I'm writing an Image class and want to use templates:
....
template<class TType, int TLayers>
class Image
{
public:
Image();
Image(std::string filename);
....
Where TType stands for int, char aso and TLayers for Grey, RGB aso.
Now, converting Images from one type to another should be possible by
using the copy constructor:
Image<short, RGB> i("blub.jpg");
Image<double, Grey> j(i);
So, I'm trying to declare the copy contructor as follows:
template<class UType, int ULayers>
Image(const Image<UType, ULayers> &img);
and implement it:
template<class UType, int ULayers>
Image<unsigned char, Grey>::Image(const Image<UType, Ulayers> &img)
{
...
};
But at compile time I get the following error:
error: no `Image<unsigned char, 1>::Image(const Image<UType, ULayers>&)'
member function declared in class `Image<unsigned char, 1>'
error: invalid function declaration
Any ideas?
Cheers
matspi