// Illustrate methods for declaring an array // (C) 2002 Bill Lenhart #include int main() { // you can omit the word "void" as a parameter // Static allocation of an array // declare an array of 10 ints int list1[10]; int i; for(i=0;i<10;i++) list1[i]=i; cout << "Here are the contents of list1: "; for(i=0;i<10;i++) cout << list1[i] << " "; cout << endl; int size; cout << "Enter size of array: "; cin >> size; // Dynamic allocation of an array // Use a "pointer to int, and allocate with new int *list2; list2 = new int[size]; // Note: Could have put all on one line: int *list2 = new int[size]; // list2 now knows how long it is // Note that the pointer list2 can be used as an array name for(int j=0;j