C++ arrays does not have any empty elements. All elements has a value.
One approach is to use a sentinel value. Simply pick a value that fits in an int
and use that to denote empty.
I'm more familiar with C than C++, but on the other hand, you seem to code things that are pretty close to C. So another approach is this:
struct Element {
int value;
bool isnull;
}
Element Heap[5];
To delete an element, simply do:
Heap[index].isnull = true;
Another approach that involves pointers:
int values[5];
int *Heap[5];
// Assign a value
values[index] = 42;
Heap[index] = &values[index];
// Delete a value
Heap[index] = NULL;