[Solved] Why i can’t delete my array pointer when i declared it with the ‘new’ keyword [closed]


Your bufferX and bufferY variables are not declared as class members but rather as variables in the asd() function/constructor and they are deleted when that function exits.

You should declare them as class members if you want to retain them.

Also, please do not post code as images, it makes it harder to help you.

class asd
{
    public:
    const char *bufferX, *bufferY;
    const char Player="0";

    asd()
    {
        bufferX= new char[16];
        bufferY= new char[16];
    }

    ~asd()
    {
        delete[] bufferX;
        delete[] bufferY;
    }
};

7

solved Why i can’t delete my array pointer when i declared it with the ‘new’ keyword [closed]