You may not call delete in this code snippet
MyObj testObj;
testObj.makeArray();
delete testObj;
because the testObj is not a pointer that was assigned by the address of memory that was allocated with using the operator new.
You need to add to the class definition at least an initializer and destructor
class MyObj {
private:
uint8_t *arrayPtr = nullptr;
public:
~MyObj() { delete [] arrayPtr; }
void makeArray();
};
Pay attention to that either you should define the copy constructor and the copy assignment operator as deleted or you have to explicitly define them.
Also bear in mind that the function makeArray is unsafe. If the user will call it the second time there will be a memory leak because the previously allocated memory will not be deleted.
And you do not have an array as a data member pf the class. You have a pointer. That pointer will be freed from the stack together with the object containing the pointer. However the dynamically allocated array will not be freed without calling the operator delete [].