1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include <iostream>
#include <vector>
using namespace std;
template<typename T>
void Print(T array[], int array_size)
{
for(int i = 0; i < array_size; i++)
cout <<array[i] <<" ";
}
template<typename T>
void print2(T vector<int> & v)
{
for (int i=1; i<=v.size(); i++) v.push_back(i);
{
std::cout << "myvector contains:";
for ( std::vector<int>::const iterator it = v.begin() ;
it != v.end();
++it)
{
std::cout << ' ' << *it;
std::cout << '\n';
}
}
}
int main ()
{
//double Array[10] = {1.3,2.44,0,3,4,2,5,6,0,7};
//Print(Array, 10);
string s[] = {"if", "you","just","think","about","it","it's","actually","quite", "easy"};
Print(s, 10);
//int vector[3] = {1,2,3};
//print2(vector);
}
| |