// file: lecture_28/t.h // // system include files // #include #include // define a simple class // class Toaster { public: // define enumerations // enum TYPES { BOSCH = 0, KITCHENAIDE, CUISENART, SUNBEAM }; enum DEBUG { NONE = 0, BRIEF, FULL }; // define a static constant // static DEBUG debug_level_d; // define protected data // protected: // define some data // char* str_d; long len_d; long width_d; float weight_d; // define public functions // public: Toaster(float weight_a = 27.0) { str_d = new char[10]; len_d = (long)0; width_d = (long)0; weight_d = weight_a; debug_level_d = NONE; } Toaster(long len_a) { len_d = len_a; } ~Toaster() { if (str_d != (char*)NULL) { delete [] str_d; str_d = (char*)NULL; } } // define some functions // bool display(FILE* fp, char* delim, long val); bool display(FILE* fp_a) { return display(fp_a, (char*)"Joe", (long)27); } bool display(Toaster arg_a) { arg_a.display(stdout); return true; } bool set_value(const long len_a = 39, long width_a = 27, float weight_a = 99.9); Toaster add(Toaster& arg1, Toaster& arg2); Toaster operator + (Toaster const &obj) { Toaster tmp; tmp.len_d = len_d + obj.len_d; return tmp; } Toaster operator - (Toaster const &obj) { Toaster tmp; tmp.len_d = len_d - obj.len_d; return tmp; } // define private functions // private: // define a function that does nothing // bool status(FILE* fp); // end of class };