#include
using namespace std;
class MyString
{
public:
MyString(chars1, char s2);
void add_str1_and_str2();
void disp();
private:
char *str1;
char str2;
char str3;
};
MyString::MyString(char s1, char s2)
{
str1 = s1;
str2 = s2;
str3 = s1;
}
void MyString::add_str1_and_str2()
{
while (*str3 != ‘\0’)
{
str3++;
}
while (*str2 != ‘\0’)
{
*str3++ = *str2++;
}
*str3 = ‘\0’;
}
void MyString::disp()
{
cout << "两字符串相加的值为" << str1 << endl;
}
int main()
{
char str1[100], str2[100];
cout << "请输入两个字符串的值" << endl;
cin >> str1;
cin >> str2;
MyString p(str1, str2);
p.add_str1_and_str2();
p.disp();
return 0;
}