测试代码:
#include<iostream>
using namespace std;
template<class X>void func(X a,int num)
{
int i;
for(i=0;i<num;i++)
cout<<' ';
cout<<a<<endl;
}
int main()
{
func(3.14,1);
func(10,3);
func('A',4);
func("hello",6);
return 0;
}
测试结果:
3.14
10
A
hello
请按任意键继续. . .