Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

doubt in template concepts

Status
Not open for further replies.

isaisa

Programmer
May 14, 2002
97
IN
hi all
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top