Chapter 9 (281-308) Summary: p303 Review: p304-305 Review Questions: 1, 9, 10, 11, 12, 14, 15, 16 -) What does the C++ keyword class do? -) Design a class for ... -) Demonstrate the proper way to define a class. -) 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. -) Demonstrate in code how to make a class. -) What is an accessor function? -) What is a mutator function? -) Why are accessor and mutator functions preferred when using classes? -) Demonstrate how to compile a class and driver. Example: A class called Help with a driver program called main.cpp is g++ Help.cpp main.cpp -o main.exe -) Preprocessor commands: #ifndef/#endif #define #include -) Why is the #ifndef expression used when creating classes? -) What is the difference between #ifndef and #define -) What is the scope resolution operator do? -) Why is the scope resolution operator necessary? -) Why should data in a class be private? -) Why should classes be defined in their own file? -) What are the interface and implementation files for a class called : Example: a class called Help is separated into Help.h and Help.cpp -) Why are interface and implementation separated? -) What is data encapsulation? -Why is it useful? -) What is information hiding? -Why is it useful?