Y
yuanhp_china
I define a class in A.h:
template <class T> class A{
public:
void get_elem( const T&) ;
};
Then I give the implementation in A.cpp (and do an explicit
instantiation ):
template<class T> void A::get_elem( const T&)
{...}
template class A<int>; //explicit instantiation
I have another two files: main.cpp and B.cpp. I would like to reuse
the explicit instantiation of A<int> of A.cpp in the two files. Do I
need to declare class A<int> in the two files? I am not sure how to do
it?
Any help are appreciated.
Hua
template <class T> class A{
public:
void get_elem( const T&) ;
};
Then I give the implementation in A.cpp (and do an explicit
instantiation ):
template<class T> void A::get_elem( const T&)
{...}
template class A<int>; //explicit instantiation
I have another two files: main.cpp and B.cpp. I would like to reuse
the explicit instantiation of A<int> of A.cpp in the two files. Do I
need to declare class A<int> in the two files? I am not sure how to do
it?
Any help are appreciated.
Hua