Q: exit code 3221225477 c++ I'm writing this code
#ifndef RECTANGLE_H
#define RECTANGLE_H
#include <iostream>
#include <cstddef>

using namespace std;

class MyString
{
public:
    MyString(const char ch, int size);
    MyString(const char chars[], int size);
    char at(int index) const;
    int length() const;
    MyString append(const MyString& s);
    MyString append(int n, char ch);
    MyString assign(const MyString& s, int index, int n);
    MyString assign(const MyString& s, int n);
    MyString assign(int n, char ch);
    MyString substr(int index, int n) const;
    MyString substr(int index) const;
    void clear();
    bool empty() const;
private:
    char* chars;
    int size;
};

MyString::MyString(const char ch, int size) 
{
    this->size = size;
    this->chars[this->size] = ch;
}

MyString::MyString(const char chars[], int size) 
{
     for(int i = 0; i < size; i++)
     {
        this->chars[i] = chars[i];
     }
    this->size = size;
}

char MyString::at(int index) const 
{
    return chars[index];
}

int MyString::length() const 
{
    return this->size;
}

MyString MyString::append(const MyString& s)
{
    const int newSize = size + s.length();
    char *newChars = new char[newSize];
    for(int i = 0; i < size; i++)
    {
        newChars[i] = chars[i];
    }
    int k = 0;
    for(int j = size; j < newSize; j++)
    {
        newChars[j] = s.chars[k];
        k++;
    }
    MyString myString(newChars, newSize);
    return myString;
}

MyString MyString::append(int n, char ch)
{
    for(int i = 0; i < n; i++)
    {
        chars[i] = ch;
    }
    MyString myString(chars, n);
    return myString;
}

MyString MyString::assign(const MyString& s, int index, int n)
{
    int j = 0;
    const int newSize = n;
    for(int i = index; i < index + n; i++)
    {
        chars[j] = s.chars[i];
        j++;
    }
    MyString myString(chars, newSize);
    return myString;
}

MyString MyString::assign(const MyString& s, int n)
{
    char *newChars = new char[n];
    for(int i = 0; i < n; i++)
    {
        newChars[i] = s.chars[i];
    }
    MyString myString(newChars, n);
    return myString;
}

MyString MyString::assign(int n, char ch)
{
    char *newChars = new char[n];
    for(int i = 0; i < n; i++)
    {
        newChars[i] = ch;
    }
    MyString myString(newChars, n);
    return  myString;
}

MyString MyString::substr(int index, int n) const
{
    const int newSize = n;
    char *newChars = new char[newSize];
    int j = 0;
    for(int i = index; i < index + n; i++)
    {
        newChars[j] = chars[i];
        j++;
    }
    MyString myString(newChars, newSize);
    return myString;
}

 MyString MyString::substr(int index) const
 {
    const int newSize = size - index;
    char *newChars = new char[newSize];
    int j = index;
    for(int i = 0; i < newSize; i++)
    {
        newChars[i] = chars[j];
        j++;
    }
    MyString myString(newChars, newSize);
    return myString;
}

void MyString::clear() //Clear all the elements in the chars array
{
    chars = NULL;
 }

bool MyString::empty() const //Check if the chars array is empty
{
    if(this->size == 0)
        return true;
    return false;
}

int main()
{
    int size1 = 5;
    char chars1[] = {'H', 'E', 'L', 'L', 'O'}; 
    int size2 = 1;
    char chars2 = 'A';
    MyString str1(chars1, size1);
    MyString str2(chars2, size2);
    cout << "str1.length() : " << str1.length() << endl;
    cout << "str1.at(3) : " << str1.at(3) << endl;
    cout << str1.append(str2).length() << endl;
    cout << "str1.substr(2)" << str1.substr(2) << endl;
    cout << str1.substr(2).at(2) << endl;
    return 0;
}
#endif

When i copile it, it doesnt show any errors. 
But When i run it,it shows errors with exit code 3221225477 with window like
TestMyString.exe has stopped working. Windows can check online for a solution to the problem. blah blah...
Please help me!

A: Your basic problem is in the constructors of MyString
MyString::MyString(const char ch, int size) 
{
    this->size = size;
    this->chars[this->size] = ch;
}

MyString::MyString(const char chars[], int size) 
{
     for(int i = 0; i < size; i++)
     {
         this->chars[i] = chars[i];
     }
     this->size = size;
}

In both cases, the chars member of MyString is a pointer, and the constructors do nothing to initialise it, let alone ensure it points at a valid area of memory, before copying data to it.   That gives undefined behaviour.
The result of the above is that, in main()
MyString str1(chars1, size1);
MyString str2(chars2, size2);

exhibit undefined behaviour.  Similarly in other places where a MyString is constructed in a similar manner.
