请教为何出现段错误

tcbsyao tcbsyao 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
1 #include <iostream>
2 using namespace std;
3 #include <string>
4
5 class String
6 {
7 char* x;
8 public:
9 String(char* x):x(0){}
10 String(const String& s){}
11 friend String operator+(const String& s2,const String& s3);
12 friend ostream& operator<<(ostream& o,const String& s1);
13
14 };
15 String operator+(const String& s2,const String& s3)
16 {
17 char* x=strcat(s2.x,s3.x);
18 return String(x);
19 }
20 ostream& operator<<(ostream& o,const String& s)
21 {
22 o<<s.x;
23 return o;
24 }
25
26 int main()
27 {
28 String string1("abc"),string2("efg"),string3("hij");
29 string1=string2+string3;
30 cout<<string1;
31 }


...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
tcbsyao
C++ 语言 65,214 成员 250,514 内容