PROGRAMMING POINTERS, LESSON 28 Syntax/correctness issues 28-1 Remember to put a semicolon at the end of a class definition. 28-2 A class constructor or destructor must not have a return type, therefore a class constructor will never attempt to return a value. 28-3 Default function arguments must be declared only in the function prototype within the class definition area. 28-4 When writing the implementation for a member function of a class, the function's name must be preceded with the return type, name of the class and the scope operator (::). For example from the time class, void time::setTime (int hour, int minute, char format); has the following meaning: the function returns no data the function setTime is a member function of class time Formatting suggestions 28-6 When selecting identifiers for private data members, use the leading word "my" to emphasize who the data belongs to. This will make it easier to keep track of data which belongs to the object versus data external to the object. In the time class we used myHour, myMinute, and myDisplay. 28-7 The member function prototypes in the class definition should be grouped according to category. For example, the constructors and destructor are usually listed first, then I/O, etc. Software engineering 28-8 The data fields for a class should be designated private. This maintains the abstraction barrier between the client program and the implementation of the ADT. 28-9 The ability to overload operators for user-defined types is a major reason for implementing user-defined types using classes instead of a struct. 28-10 The entire class definition and implementation should be surrounded by the preprocessor directives, #ifndef classname #define classname class declarations #endif This avoids the problem of the compiler trying to compile a file twice. If a file has already been compiled, a second compilation would cause problems.