Quizzes and Extra Credit for Week 7.
Post your answers to the Quizzes from Week 7 here rather than in the chapter thread, so as not to spoil things for the others.Chapter 8 Quiz 1. What is a pointer? 2. What is a variables address? 3. What operator do you use to get the address of a variable? 4. How would you declare a variable which is a pointer to a character? 5. How would you assign the address of a character to a character pointer variable? 6. What is it called when you use a pointer variable to obtain the data stored at the address it holds? 7. Why must we tell the compiler what type a pointer is, if all pointers are the same size? 8. What operator do you use to indirectly get the data stored at the address held by a pointer? 9. If you allocate memory on the heap while in a function, is the data available after the function returns? 10. Why are destructors so critical? 11. How would you allocate a ‘char’ on the heap and store the address so as to access the data later? 12. How would you set the value of the data in question 11 to the character ‘c’. 13. What keyword do you use to return the memory you’ve allocated back to the operating system? 14. What is it called when you have unused memory which is not freed until the progam ends either because the program author failed to release the memory when finished, or the address to the memory was lost, making it impossible to free. 15. In addition to allocating memory for an object, what function is always called on an object after it is created with ‘new’? 16. What function is called when you use the delete operator on an object, just before the memory is freed? 17. What is the long-hand way of accessing methods or data on an object indirectly via a pointer? Show an example to illustrate. 18. What is the short-hand way of doing the same thing as in question 17. 19. What is ‘this’? 20. What is a dangling pointer? 21. What’s different between “const int*”, “int * const”, and “const int * const”? How are these read? 22. If you have a pointer to a constant object, which member functions can be called on that object? Good luck! [Edited by - jwalsh on July 29, 2006 11:39:15 AM]