Give the sequence of steps for creating and using a dynamic array.

What will be an ideal response?

) define a pointer type for pointers to variables of the type the elements are to be
typedef double * doublePtr’
b) declare a pointer variable of the defined type to point to the dynamically allocated array.
doublePtr a;
c) assign to the pointer variable the returned value from a call to new
a = new double[arraySize];
d) use as you would any array.
a[4] = 17.94;
e) before the end of the block where the pointer variable is declared, call the delete operator with the pointer variable as argument. Note the syntax for the deletion of memory allocated as an array.
delete [] a;

Computer Science & Information Technology

You might also like to view...

Laser printers require ________ to produce printed documents

A) ink cartridges B) toner ink C) toner powder D) liquid ink

Computer Science & Information Technology

What command-line interface can be used to “wipe” an application database?

a. emulatorwipe b. JUnit c. cleardatabase d. sqlite3

Computer Science & Information Technology