if we put template class member function defination in .cpp(not in headerfile) with explicit instant

Posted by user323422 on Stack Overflow See other posts from Stack Overflow or by user323422
Published on 2010-04-29T09:38:17Z Indexed on 2010/04/29 9:47 UTC
Read the original article Hit count: 338

Filed under:
|

For example

//temp.h
class ABC
{
  pubilc: void temp(T &a);
};

//temp.cpp( )
void ABc<T>::temp(T &a){} //defination ( it should be in header file?????????)
template class ABC<int>;

//main.cpp
int main()
{
  int i=10;
  ABC<int> a;
  a.temp(i);
return 0;
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about templates