Hi,
this is C++ and not PHP but I think you OOP guy will help me about my issue.
I'm developing a C++ class that will write to a graphic-LCD-controller (a small 320x240 pixel display that could be BW or 256colors).
Basically now I'm using this:
the refresh method is different based on the mode and based on the orientation.Code:class dev_Lcd { public: enum Mode {BLACKWHITE, COLORS}; enum Orientation {PORTRAIT, LANDSCAPE}; private: Mode d_mode; Orientation d_orientation; public: // CREATORS dev_Lcd(Mode mode, Orientation orientation); ~dev_Lcd(); // MANIPULATORS void refresh(const char *screen); };
So in pratice the refresh has a ``switch'' based on d_mode and d_orientation.
I was thinking to use another method, though.
what would you use ?Code:// BASE CLASS for common things class dev_Lcd { public: // CREATORS dev_Lcd(); ~dev_Lcd(); // MANIPULATORS virtual void refresh(const char *screen); }; class dev_LcdBwPortrait : public dev_Lcd { public: // CREATORS dev_LcdBwPortrait(); ~dev_LcdBwPortrait(); // MANIPULATORS void refresh(const char *screen); }; class dev_LcdBwLandscape : public dev_Lcd { public: // CREATORS dev_LcdBwLandscape (); ~dev_LcdBwLandscape (); // MANIPULATORS void refresh(const char *screen); }; // same for color mode
Approach 1) or 2) ?
Criticisms are welcomed...thanks![]()






Bookmarks