D
D.Cakirkaya
I'm having multiply-defined error for a non-static member function
(e.g Check ) of my class template (e.g. Processor) when I specialize
it for the same set of arguments (e.g T, U, V and X, Y, Z) as those
that I use to instantiate my template classes (e.g. TUVProcessor and
XYZProcessor). I sure do understand that this not unexpected ( as I
instantiate my template class ProcessorXYZ, the resulting entity is a
specialization of Processor for arguments X, Y, Z and hence the
'multiple-definition'... )
Is there any fast-syntactic turnaround for this link-error?
(Note: I'm using CC compiler (Sun C++ 5.9 SunOs_sparc))
// in file Processor.h
template <class T, class U, class V>
class Processor
{
public:
bool Check();
};
//fully specialized for args T, U, V
template<> bool
Processor<T, U, V>::Check()
{
return true;
}
//fully specialized for args X, Y, Z
template<> bool
Processor<X, Y, Z>::Check()
{
return true;
}
//In file Component.cpp
//The instantiation of the template classes for the same set of
arguments
typedef Processor<T, U, V> TUVProcessor;
typedef Processor<X, Y, Z> XYZProcessor;
TUVProcessor* p1 = new TUVProcessor;
XYZProcessor* p2 = new XYZProcessor;
// file ComponentDeployer includes Component.h (and registers the
component)
//Error message goes like " Multiply-defined in Component.o and
ComponentDeployer.o "...
(e.g Check ) of my class template (e.g. Processor) when I specialize
it for the same set of arguments (e.g T, U, V and X, Y, Z) as those
that I use to instantiate my template classes (e.g. TUVProcessor and
XYZProcessor). I sure do understand that this not unexpected ( as I
instantiate my template class ProcessorXYZ, the resulting entity is a
specialization of Processor for arguments X, Y, Z and hence the
'multiple-definition'... )
Is there any fast-syntactic turnaround for this link-error?
(Note: I'm using CC compiler (Sun C++ 5.9 SunOs_sparc))
// in file Processor.h
template <class T, class U, class V>
class Processor
{
public:
bool Check();
};
//fully specialized for args T, U, V
template<> bool
Processor<T, U, V>::Check()
{
return true;
}
//fully specialized for args X, Y, Z
template<> bool
Processor<X, Y, Z>::Check()
{
return true;
}
//In file Component.cpp
//The instantiation of the template classes for the same set of
arguments
typedef Processor<T, U, V> TUVProcessor;
typedef Processor<X, Y, Z> XYZProcessor;
TUVProcessor* p1 = new TUVProcessor;
XYZProcessor* p2 = new XYZProcessor;
// file ComponentDeployer includes Component.h (and registers the
component)
//Error message goes like " Multiply-defined in Component.o and
ComponentDeployer.o "...