hi all
i have come across one dount while reading templates. Following is the code snippet about the query
in the code above, the member function for the template class is non dependent on the template parameter. when using the class template in statement 1 & 2, how does the compiler handles the situation? weather it creates the seperate copy of member function foo() for every instantiation of the template or it refers to the same copy where it encounters the first Point Of Instantiation [POI] ?
thanks in advance
sanjay
i have come across one dount while reading templates. Following is the code snippet about the query
Code:
template <typename T>
class Test {
void foo() {
cout << "test function" << endl;
}
};
// Code using class template above
Test<double> doubleTest; // Statement 1
Test<int> intTest; // Statement 2
in the code above, the member function for the template class is non dependent on the template parameter. when using the class template in statement 1 & 2, how does the compiler handles the situation? weather it creates the seperate copy of member function foo() for every instantiation of the template or it refers to the same copy where it encounters the first Point Of Instantiation [POI] ?
thanks in advance
sanjay