It's well-defined; you're creating an array, passing a valid pointer to the constructor (which takes a pointer, despite looking as though it takes an array), storing that pointer, and then accessing a valid array element through it.
The only problem is the memory leak - you never delete the array.
UPDATE Now you've added a destructor to delete the array, the class is very dangerous - if you copy it, then both copies will try to delete the same array. That will cause undefined behaviour. You need to either prevent copying, or implement it correctly, per the Rule of Three. You'll also get undefined behaviour if the pointer isn't to an array created with new[]
.
Once you've learnt how to manage resources by hand, and how difficult it is to get all the details right, you would usually use a library class to do it for you. In this case, std::vector<int>
would be ideal. Doing this is sometimes called the "Rule of Zero" (as mentioned in the comments), as it removes the need to write your own destructor or copy/move semantics at all - they all come from the class(es) you're using, which someone has already implemented correctly.