64,682
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
using namespace std;
template<typename T1,typename T2>
class tem
{
public:
tem(T1 a,T2 b);
~tem();
void output();
T1 * h;
};
template<typename T1, typename T2>
tem<T1,T2 >::tem(T1 a, T2 b)
{
h=new T1 [b+1];
for(int i=0; i<b;i++)
h[i]=0;
for(int i=0; i<b;i++)
h[i]=a;
}
template<typename T1, typename T2>
tem<T1,T2>::~tem ()
{
delete [] h;
cout<<"-----析构-----";
}
template<typename T1,typename T2>
void tem<typename T1,typename T2>::output()
{
cout<<h;
}
void main()
{
{
int a=5;
char i ='A';
tem<char,int> b(i,a);
b.output ();
// b.~tem ();
}
int P;cin>>P;
}
h=new T1 [b+1];//==》h=new T1
cout<<h;//==>cout<<h<<endl;
[b