I was reading this tutorial on Templates and when it came to function templates I found this snippet of code and text
template <class myType>
myType GetMax (myType a, myType b) {
return (a>b?a:b);
}
GetMax <int> (x,y);
When the compiler encounters this call to a template function, it uses the template to automatically generate a function replacing each appearance of myType by the type passed as the actual template parameter (int in this case) and then calls it. This process is automatically performed by the compiler and is invisible to the programmer.
So how does instantiation work out in the case of Class Templates? The documentation there did not throw any light on this topic. Does it happen when
- I create the object
- Call the function for the first time
- Every time I call the function
Can someone please throw some light on this topic