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 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.