这是我的代码:
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
template <class T1, class T2>
void copy2(const T1 source[], T2 destination[] , int size){
for (int i=0 ; i < size ; ++i){
destination[i]=static_cast<T1>(source[i]);
}
}
int main() {
const char one[] = "hello";
char two[5];
cout << "one: " << one << endl;
cout << "two: " << two << endl;
copy2(one, two, 6);
cout << "one: " << one << endl;
cout << "two: " << …Run Code Online (Sandbox Code Playgroud)