Chapter 9: Problem 30
Write the definition of ptr, a constant pointer to an int.
Short Answer
Expert verified
Answer: To define a constant pointer to an integer variable in C++, follow these steps:
1. Initialize an integer variable, e.g. `int num = 5;`
2. Define the constant pointer using the syntax `int * const ptr = #`, where 'ptr' is the constant pointer pointing to the memory location of 'num'.
3. Use the constant pointer in your code, where the address it points to cannot be changed.