所以这是哪里出了问题?

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include<iostream>
#include<cstring>
#include<cstdlib>

using namespace std;

class String {
friend ostream &operator<<(ostream &, String &);

friend istream &operator>>(istream &, String &);

public:
String();

String(const char *str);

String(const String &rhs);

String(String &&rhs) noexcept ;

String &operator=(const String &rhs);

String operator+(const String &rhs) const;

String &operator=(String &&rhs) noexcept ;

String Substring (int Begin,int End);

char &operator[](unsigned int);

size_t size() const;

~String();

private:
char *m_data;
};

String::String()
: m_data(new char[1]) {
m_data[0] = '\0';
}

String::String(const char *str)
: m_data(new char[strlen(str) + 1]) {
strcpy(m_data, str);
}

String::String(const String &rhs) {
m_data = new char[strlen(rhs.m_data) + 1];
strcpy(m_data, rhs.m_data);
}

String::String(String &&rhs) noexcept {
m_data=rhs.m_data;
rhs.m_data=nullptr;
}

String &String::operator=(const String &rhs) {
if (this == &rhs)
return *this;
delete[] m_data;
m_data = new char[strlen(rhs.m_data) + 1];
// m_data = new char[strlen(rhs.m_data)];
strcpy(m_data, rhs.m_data);
return *this;
}

String &String::operator=(String &&rhs) noexcept{
if (this != &rhs) {
delete[] m_data;
m_data = rhs.m_data;
rhs.m_data = nullptr;
}
return *this;
}


String::~String() {
delete[] m_data;
}

String String::operator+(const String &rhs) const {
String newStr;
newStr.m_data = new char[strlen(m_data) + strlen(rhs.m_data) + 1];
strcpy(newStr.m_data, m_data);
strcat(newStr.m_data, rhs.m_data);
return newStr;
}

char &String::operator[](unsigned int index) {

return m_data[index];

}

size_t String::size() const
{
return strlen(m_data);
}

String String::Substring(int Begin, int Number) {
String newStr;
newStr.m_data=new char[Number+1];
int oldLenth=Begin;
for(int i=0;i<Number;i++){
newStr[i]=this->operator[](oldLenth);
oldLenth++;
}
newStr[oldLenth]='\0';
//cout<<newStr<<endl;
return newStr;
}


ostream &operator<<(ostream &os, String &str) {
os << str.m_data;
return os;
}

istream &operator>>(istream &is, String &str) {
char temp[255];
is >> temp;
str = temp;
return is;
}

int main(){
String s[5];
cin>>s[1];
cin>>s[2];
char Case;
while(cin>>Case){
if(Case=='P'){
int i;
cin>>i;
cout<<s[i]<<endl;
continue;
}
if(Case=='C'){
int i,j,k;
cin>>i>>j>>k;
s[k]=s[i]+s[j];
continue;
}
if(Case=='F'){
int i,j,l,k;
cin>>i>>j>>l>>k;
s[k]=s[i].Substring(j,l);
continue;
}
if(Case=='A'){
int i,j;
cin>>i>>j;
s[j]=s[i];
continue;
}
}
}