C++

Topic: Templates

How can you force instantiation of a template?

you can instantiat a template in two ways. 1. Implicit instantiation and 2. Explicit Instantion. implicit instatanitioan can be done by the following ways:<br><br>template <class T><br><br>class A<br><br>{<br><br>public: <br><br>A(){}<br><br>~A(){}<br><br>void x();<br><br>void z();<br><br>};<br><br>void main()<br><br>{<br><br>A<int> ai;<br><br>A<float> af;<br><br>}<br><br>External Instantion can be done the following way:<br><br>int main()<br><br>{<br><br>template class A<int>;<br><br>template class A<float>;<br><br>}<br>

Browse random answers: