Chapter 9 - Answer to class quiz and notes. PDF

Title Chapter 9 - Answer to class quiz and notes.
Author Deepak Menon
Course C++ Programming: Objects
Institution Riverside City College
Pages 3
File Size 37.8 KB
File Type PDF
Total Downloads 86
Total Views 136

Summary

Answer to class quiz and notes....


Description

Menon 1

Chapter 9 Review Exercises 1. The indirection operator dereferences the variable/element to the actual value. 2. 7. Nothing will happen. 3. Multiplication. Dereference and Pointer 4. ++, --, +, -, +=, -= 5. 4 will be added to int 6. 8 7. The new operator is used to dynamically allocate memory to an array 8. New compilers will display an error and terminate the program. Old compilers will reach the end of the array and restart with 0 element. 9. delete operator removes the allocated memory and allow new arrays to be allocated 10. Conditions: A pointer to an element that was passed into the function as an argument or a pointer to a dynamically allocated chunk of memory. 11. A pointer to const points to a constant item. The element the pointer points to is a constant. While with a const pointer, the pointer itself is the constant and cannot change. The address of such a pointer will always be a constant. 12. A constant pointer will have a constant address that cannot be changed by the function. Also data can be changed for the pointer without changing the address.

Find the Error 48. * operator is in the wrong place. 49. x isn't a pointer. 50. It should be ptr not *ptr. 51. No error 52. Should be *(numbers + 3) 53. Should be *ptr = 2 54. ivalue is used before it's defined

Menon 1 55. val is not a pointer; no need for first * 56. Should be ptr = new int 58. Should be *ptr = 100 59. Should be delete [] pint 59. Return the address (hint: &) 60. * cannot be used 61. [] needed 62. * must be after const Programming Challenges

1. /* Name: Deepak Menon Date: 05/28/2014 Purpose: Array Allocator */

//libraries #include using namespace std; //Functions int new(int); //Global Arrays int new[n]={};

//Execution Begins here int main() { //Variables int now; //Prompt the user for dynamically allocation

Menon 1 coutnow; int new(int); } int new(int now){ int *numb; numb = new int; int new[numb]={}; return numb; }...


Similar Free PDFs