// using dynamic memory with arrays // Michael L. Collard // 11/4/99 #include using std::cout; using std::endl; int main() { const int size = 5; // pn points to a new integer with an initial value of 4 int* pn = new int(4); // ar points to a block of MAX_size new integers from the heap // Note use of brackets int* ap = new int[size]; // can treat ap just like an array for (int i = 0; i < size; ++i){ ap[i] = i; cout << ap[i] << " "; } cout << endl; delete [] ap; // get rid of memory allocated to ap. Note use of brackets. delete pn; // get rid of memory allocated to pn }