0

Hi friends,

Can you pls tell me about "**explicit template instantiation**". Suppose I have a simple program :

1. File : TClass.h

```
#ifndef CTCLASS_H
#define CTCLASS_H
template<class T>
class CTClass
{
public:
CTClass(T t1, T t2);
~CTClass();
T add();
private:
T cm_T1;
T cm_T2;
};
template<class T>
CTClass<T>::CTClass(T t1,T t2)
:cm_T1(t1),cm_T2(t2)
{
}
template<class T>
CTClass<T>::~CTClass()
{
}
template<class T>
T CTClass<T>::add()
{
return cm_T1 + cm_T2;
}
#endif
```

And in main.cpp

```
#include <iostream>
#include "TClass.h"
using namespace std;
int main()
{
CTClass<int> l_aCTClass_int(10,20);
int sum = l_aCTClass_int.add();
cout<<"sum :: "<<sum<<endl;
return 0;
}
```

This is an implicit template instantiation. Now pls tell how and why I can use "**explicit template instantiation**" in the above example.

Thanx,

Amit