#include<iostream>
class String
{
char* p;
int len;
public:
String() { p = NULL; }
void show();
void set();
friend String operator +(const String& c1, const String& c2);
~String() { delete[]p; }
};
#pragma warning(disable:4996)
#include<iostream>
#include "String.h"
using namespace std;
void String::show()
{
cout << "字符为:" << *p << endl;
}
void String::set()
{
char* q;
q = NULL;
cout << "请输入字符" << endl;
cin >> q;
*p = *q;
len = sizeof(*p);
}
String operator +(String& c1,String& c2)
{
String next;
next.p = new char[c1.len + c2.len + 1];
strcpy(next.p, c1.p);
strcat(next.p, c2.p);
return next;
}
int main()
{
String a, b, c;
a.set();
a.show();
b.set();
b.show();
c = a + b;
c.show();
}