#include #include using namespace std; int main() { cout << "How many ints do you want to store? "; size_t n {0}; cin >> n; try { //This q can read and write. int *const p {new int[n]}; for (int *q {p}; q < p+n; ++q) { cout << "Please input int number " << q-p << ": "; cin >> *q; } cout << "Here are the ints that you input:\n"; //This q can read but not write. for (const int *q {p}; q < p+n; ++q) { cout << q-p << ": " << *q << "\n"; } delete[] p; } catch (bad_alloc e) { cerr << "Sorry, Linux has no room for " << n << " ints.\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; }