Hi,
When i do the following specializition which commented in the source then
including the header in two cpp files gives me an error:
test3.obj : error LNK2005: "class A<int* __cdecl makeA<int>(void)"
(??$makeA@H@@YAPAV?$A@H@@XZ) already defined in testSTL.obj
Can you please tell me how i can specialize the template function and still
use the header in multiple cpp files.
Thank you in advance!
Bar
//HEADER
#pragma once
template <class Tclass A;
template <class TA<T>* makeA();
template <typename T>
class A{
private:
A(){}
T _a;
public:
friend A *makeA<>(); //error in g++-3.4, works with g++3.3
};
template <typename T>
A<T>* makeA(){
return new A<T>;
}
//SPECIALIZATION GIVING PROBLEM
template <>
A<int>* makeA(){
return new A<int>;
}
//END PROBLEM SPECIALIZATION
// end header
//CPP
int _tmain(int argc, _TCHAR* argv[])
{
A<int>* a = makeA<int>();
}