To be sure that your array has valid size and you are able to iterate through it, use constants instead of defines. The preferable type is "size_t" which is unsigned integer that can fit any possible size of any array.
Here is what your code should look like after adding dynamic allocation of array:
Code:
#include <iostream>
#include "heap.h"
#include <ctime>
#include <cstdlib>
const size_t N=3000000;
int main()
{
double* arr=new double[N];
srand(time(0));
for(size_t i = 0; i<N; i++)
arr[i] = double (rand() % 100000 / 3.1 );
Heap ar(arr,N);
ar.sort();
ar.show();
delete arr;
return 0;
}
However, you can achieve better code using STL containers and algorithms. There is a standart sorting function in C++, why not to use it?
Code:
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cstdlib>
const size_t N=3000000;
int main()
{
std::vector<double> arr(N);
srand(time(0));
for(size_t i = 0; i<arr.size(); i++)
arr[i] = double (rand() % 100000 / 3.1 );
std::sort(arr.begin(),arr.end());
for(size_t i = 0; i<arr.size(); i++)
std::cout<<arr[i]<<std::endl;
return 0;
}