Cout prints an array of dynamic characters

-sharpinclude <iostream>
using namespace std;

class mstring
{
public:
    mstring(const char* str)
    {
        length = strlen(str);
        m_char = new char(length + 1);
        
        strcpy_s(m_char, length + 1, const_cast<char*>(str));
    }

    friend ostream& operator<<(ostream& out,const mstring& str)
    {
        if (NULL != str.m_char)
        {
            out << str.m_char;
            return out;
        }
    }

    ~mstring()
    {
        if (m_char != NULL)
        {
            delete m_char;
            length = 0;
        }       
    }

    char* m_char;
    int length;

};

int main()
{
    mstring* mstr = new mstring("Hello World!");
    cout << mstr;

    return 0;
}`

Why does memory go wrong?

CPP
Apr.01,2021

first of all, the mstr you created is not released, and there is no delete after new
. Secondly, there is no override in the friend function. What does if return if it doesn't go in?
and the upstairs new char ()-> new char []


char () is changed to char []

Menu