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 []

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32392-2ab3f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32392-2ab3f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?