I am trying to create a gui that has a SimpleWindow class that contains a textPanel class:
class textPanel{ private: std::string text_m; public: textPanel(std::string str):text_m(str){} ~textPanel(); }; class SimpleWindow{ public: SimpleWindow(); ~SimpleWindow(); textPanel text_panel_m; }; SimpleWindow::SimpleWindow(): text_panel_m(std::string temp("default value")) { }
I want to be able to initialize text_panel_m using const char *, which converts to std :: string without having to create another constructor that accepts const char *. Should I just create another constructor with const char * as an argument? If I do this, is this a way to reduce the amount of redundant constructor code using C ++ 0x?
With the approach above, I am having difficulty initializing member_panel_m variable. g ++ gives me the following error:
simpleWindow.cpp:49: error: expected primary-expression before 'temp' simpleWindow.cpp: In member function 'bool SimpleWindow::drawText(std::string)':
How do I start initializing member_panel_m without using the default constructor?
source share