Class A
{
Public
Template<class t>
void Testvector (std::vector<t>& values)
{
for (int i = 0; i < values.size (); i++)
{
std::cout<<values[i]<<std::endl;
}
}
};
Template<class t>
Class B
{
Public
B () {std::cout<< "B" <<STD::ENDL;}
B (T a) {std::cout<< "b (int a)" <<STD::ENDL;}
};
Template<class t>
Class C:public B<t>
{
Public
C () {std::cout<< "C" <<STD::ENDL;}
C (t A, T B) {std::cout<< "C (int a, int b)" <<STD::ENDL;
};
int main ()
{
A;
Std::vector<double> dvalues;
Dvalues.push_back (1.1);
Dvalues.push_back (2.1);
Dvalues.push_back (3.1);
Dvalues.push_back (4.1);
Dvalues.push_back (5.1);
A.testvector (dvalues);
Std::vector<int> ivalues;
Ivalues.push_back (11);
Ivalues.push_back (21);
Ivalues.push_back (31);
Ivalues.push_back (41);
Ivalues.push_back (51);
A.testvector (ivalues);
B<int> B (1);
C<int> c (+);
cout << "Hello world!" << Endl;
return 0;
}
Use of C + + function templates and class templates