C++string类,定义字符串数组实现功能

#include 
#define maxsize 1000
using namespace std;
class String
{
    public:
        char str[maxsize];
        void init()
        {
            cin >> str;
        }
        void show()
        {
            cout << str << endl;
        }
        int length_str()
        {
            int length = 0;
            for (int i = 0; str[i] != '\0'; i++)
            {
                length++;
            }
            return length;
        }
        char substring(int beginIndex, int endIndex)
        {
            for (int i = beginIndex; str[i] != '\0'; i++)
            {
                if (i <= endIndex)
                {
                    cout << str[i];
                }
                else if (i > endIndex)
                {
                    break;
                }
            }
            return str[maxsize];
        }
        char* connect_str(char* str1, char* str2)
        {
            char* c = str1;
            while (*str1 != '\0')
            {
                str1++;
            }
            while (*str2 != '\0')
            {
                *str1 = *str2;
                str1++;
                str2++;
            }
            *str1 = *str2;
            return c;
        }
};

int main()
{
    String str1, str2;
    int length, begin, end;
    cout << "请输入字符串str1:" << endl;
    str1.init();
    cout << "字符串str1为:" << endl;
    str1.show();
    length=str1.length_str();
    cout << "字符串str1的长度为:" << endl;
    cout << length << endl;
    cout << "请输入区间:" << endl;
    cin >> begin >> end;
    cout << "字符串str1区间" << begin << "," << end << "为:" << endl;
    cout << str1.substring(begin, end) << endl;
    cout << "请输入字符串str2:" << endl;
    str2.init();
    cout << "连接后的字符串为:" << endl;
    cout << str1.connect_str(str1, str2) << endl;
    return 0;
}

报错:

img


希望能实现代码中所有功能(字符串数组初始化,输出,求长度,连接两个字符串,输出字符串数组区间[a,b]的内容)。