I am trying to implement a heap. I have built a class to store an array of integers, the number of ints currently in the array and the total size of the array. When I invoke the insert method, the total size variable gets changed but the code does not explicitly do it. The code is as follows:
You're overwriting memory, that's why. Arrays can't be made dynamically like that, you have to use new and delete. For proof of the memory overwriting, try changing line 34 to insert 42 instead of 10.