032 这个模板并不难
作者:互联网
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
template <class T>
class myclass {
// 在此处补充你的代码
public:
T * p;
int size;
myclass(){}
myclass(T * ar,int l): size(l){
p = new T[size];
for (int i = 0;i < size;i++) {
p[i] = ar[i];
}
}
~myclass() {
delete[] p;
}
void Show()
{
for (int i = 0;i < size;i++) {
cout << p[i] << ",";
}
cout << endl;
}
};
int a[100];
int main() {
char line[100];
while (cin >> line) {
myclass<char> obj(line, strlen(line));;
obj.Show();
int n;
cin >> n;
for (int i = 0;i < n; ++i)
cin >> a[i];
myclass<int> obj2(a, n);
obj2.Show();
}
return 0;
}
标签:include,Show,int,032,myclass,line,不难,模板,size 来源: https://www.cnblogs.com/icefield817/p/15931306.html