This text includes sections from chapters 7,9 and 13. The quiz reviews display many questions for chapters 7 and 9. Those are quoted below. In addition, at the end of this review you will find several questions regarding Chapter 13. I encourage you to first, read the sections, and then try review problems in the book. When that is complete, you should try these problems and understand their solutions. This set of questions is not a complete list (and some of the questions are half-formed, so there is no guarantee that any of these will appear on the quizzes). ------------------------------------------------------------------- Chapter 7 (through 7.8) ------------------------------------------------------------------ Short Answer Questions ------------------------------------------------------------------ 1) Explain how to determine if a C++ program uses dynamic memory. 2) Name at least two major advantages to using dynamic arrays over static arrays. 3) Name a major disadvantage of using dynamic arrays over static arrays. 4) What is the dereferencing operator? 5) What does the dereference operator do? 6) What is the "address of" operator? 7) Convert the following code to use dynamic arrays instead of static arrays. //code for this problem would go here 8) Find the errors in the following code: //code for this problem would go here 9) Demonstrate how to declare a dynamic array (of a specific type) with size input by the user. 10) Why do arrays act like call by reference? 11) Why does every new require a delete? 12) What is the keyword 'new' used for in C++? 13) What is the keyword 'delete' used for in C++? 14) Show a function prototype that passes a dynamic array. 15) What is NULL and how is it used? 16) Demonstrate, in code, how to declare an array with a size determined by the user of the program. ------------------------------------------------------------------ True or False example questions (some of the statements below are true and some are false) ------------------------------------------------------------------ a) Arrays act like call by reference because arrays are dynamic. b) Array names are pointers. c) Static arrays are declared with new. d) Static arrays are declared with a constant size that must be determined at compile time. e) Dynamic memory goes on the heap. f) Dynamic memory does not go on the heap. g) Dynamic memory is destroyed at the end of a function or code block. h) Dynamic memory is not destroyed at the end of a function or code block. ------------------------------------------------------------------- Chapter 9 ------------------------------------------------------------------ Short Answer Questions ------------------------------------------------------------------ 1) What does the C++ keyword struct do? 2) What does the C++ keyword class do? 3) What is data encapsulation? 4) What is information hiding? 5) Why are classes safer than structs? 6) Demonstrate in code how to make a class. 7) Variables describe an is-a relationship while classes describe a have-a relationship. Example - consider the following two code segments: //segment 1 int a; // a is an integer. //segment 2 class Date { private: //accessors mutators and other functions go here public: int month; int day; int year; }; //Date has-a day month and year. 8) What is an accessor function? 9) What is a mutator function? 10) Why are accessor and mutator functions necessary when using classes and not necessary when using structs? Be sure to describe why to both. 11) Design a class for ... 12) Demonstrate the proper way to define a class. 13) Given a class called Help, demonstrate how to compile the class's implementation file and the main program file called main.cpp. 14) Given a class called Help, what two files should be associated with this class. Describe what these two files do/What is their purpose? 15) What does #include do? 16) What is a preprocessor command? Name two. 17) What is the difference between #ifndef and #define? 18) What is the scope resolution operator? 19) What does the scope resolution operator do? 20) Why is the scope resolution operator necessary? ------------------------------------------------------------------ True or False example questions (some of the statements below are true and some are false) ------------------------------------------------------------------ 1) All data in a struct is public. 2) All data in a struct is private. 3) All data in a class is public. 4) All data in a class is private. 5) Classes are safer than structs. 6) Structs are safer than classes. 7) #include is used to properly protect a header file from multiple inclusions. 8) #ifndef is used to properly protect a header file from multiple inclusions. 9) #include is used to incorporate class header files and function prototypes into a program or implementation file. 10) #endif is needed after a #define. 11) #endif is needed after a #ifndef. 12) #endif is needed after a #include. 13) Classes should be defined in separate files. 14) Classes should be defined in the main program file. ------------------------------------------------------------------ Chapter 13 (section 13.8 only) ------------------------------------------------------------------ 1. What is the friend keyword used for in C++? 2. What is overloaded input? 3. What is overloaded output? 4. Demonstrate how to overload input for . . . 5. Demonstrate how to overload output for . . . 6. How does one use cout with a user defined type? 7. How does one use cin with a user defined type? 8. What is the output of the following code . . . ------------------------------------------------------------------ True/False ------------------------------------------------------------------ 1. friend is necessary for mutator functions 2. friend is not necessary for mutator functions 3. friend is necessary for accessor functions 4. friend is not necessary for accessor functions 5. friend is necessary for overloaded input 6. friend is not necessary for overloaded input 7. friend is necessary for overloaded output 8. friend is not necessary for overloaded input