If you really want to allocate an array of 2,000,000,000 doubles why not just do it directly?
double *A1 = new double[ ARRAY_SIZE ];
If you want to have a distinctly named large object bin the typedef and use
struct DoubleArray_T
{
double data[ ARRAY_SIZE ];
};
DoubleArray_T *A1 = new DoubleArray_T;
instead. This makes the array behave more like an object than the typedef does. Remember a typedef only introduces an alias for another type and that pointers to arrays (as
DoubleArray_T *
was in your code) are really strange beasts unless you know what you're doing. In your original code
new DoubleArray_T
was returning a pointer to a double and you were trying to assign that to a
DoubleArray_T *
, which are different types.
Cheers,
Ash
PS: Edited to make it at least look English