A good fix would be:
class stack
{
std::vector<int> arrays;
int top;
public:
stack(int maxsize) : arrays(maxsize), top(0) {}
};
This way, you do not have any possibility of memory management bugs; your class behaves properly when copied, moved, swapped, etc. and your code is very simple.
An alternative, with a minimal memory footprint would be:
class stack
{
std::unique_ptr<int[]> arrays;
int maxsize;
int top;
public:
stack(int maxsize) : arrays(new int[maxsize]), maxsize(maxsize), top(0) {}
};
This version is movable, but will give compile errors when copied (as opposed to some of the other suggestions to use raw pointer, which will compile successfully and then give memory corruption at runtime). To make this class copyable you'd need to write your own copy-constructor and copy-assignment operator.