#include #include #include class textbox { // a class to handle a graphic text string // not fully implemented: public: // some kind of constructor? // change the text void settext(const string &text) { s = text; } void settext(string &&text) { s = std::move(text); } void settext(const char *text) { s = text; } // draw methods? // change font methods? // etc... private: string s; // other private fields }; class scatterplot { // a class to draw a scatter plot // not fully implemented: public: // some kind of constructor // to avoid set up costs (connecting to the display, etc) // this class provides a method to completely change the plot: void newplot(const string &title, const string &xlabel, const string &ylabel, const map &points) { titlebox.settext(title); xaxisbox.settext(title); yaxisbox.settext(title); pts = points; // recalculate axis ticks, etc // call code to redraw } // but what if title, xlabel, ylabel, points are r-values? // to use above, they get converted to l-value refs and the // advantage is lost // Futhermore, we canot pass a const char * directly (although // type conversion will solve this). Perhaps "textbox" has a // faster implementation if a char * is passed in directly? // (same problem happens for constructors, frequently!) // or even simple setters (like "changetitle") that only pass along // one parameter/message. void newplot(string &&title, string &&xlabel, string &&ylabel, map &&points) { titlebox.settext(move(title)); xaxisbox.settext(move(title)); yaxisbox.settext(move(title)); pts = move(points); // recalculate axis ticks, etc // call code to redraw } private: textbox titlebox, xaxisbox, yaxisbox; map pts; };