Another implicit C++ class template instantiation program example

 

Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows XP Pro SP2

Header file: Standard

Additional library: none/default

Additional project setting: Set project to be compiled as C++

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)

Other info: none

To do: Creating and using the implicit  C++ class template instantiation in C++ programming

To show: How to create and use the implicit  C++ class template instantiation in C++ programming

 

// another C++ implicit template instantiation

#include <iostream>

using namespace std;

 

template <class any_data_type>

class TestVirt

{

public:

virtual any_data_type TestFunct(any_data_type Var1)

{return Var1;}

};

 

// do some testing

int main(void)

{

// implicit instantiation of TestVirt<int>

TestVirt<int> Var1;

cout<<"Var1.TestFunct(100) = "<<Var1.TestFunct(100)<<endl;

return 0;

}

 

Output examples:

 

Var1.TestFunct(100) = 100

Press any key to continue . . .

 

 

C and C++ Programming Resources | C & C++ Code Example Index