
Thanks for the reply. But I am still unsure where I should invoke this static method. 1) I need the member variables initialized...and if I cant do it in the constructor, then where should I? 2) Also, your sample code does not use shared_from_this() ... I would like to learn how to correctly use shared_from_this() because I'll be using it in other places in my code too. Thanks, /C. 2008/9/6 Igor R <boost.lists@gmail.com>
TextTool::TextTool(QDialog *taskDialogue) : Tool(this->name) { boost::shared_ptr<TextTool> pointerToThis = TextTool::shared_from_this(); //ERROR OCCURS ON THIS LINE
bold = boost::shared_ptr<ToggleControl>(new ToggleControl(pointerToThis)); }
You cannot call shared_from_this in the constructor. Instead, you can define a static constructing method, like this:
// untested!! static boost::shared_ptr<TextTool> TextTool::create(QDialog *taskDialogue) { boost::shared_ptr<TextTool> pointerToThis(new TextTool(taskDialogue)); pointerToThis->bold.reset(new ToggleControl(pointerToThis)); return pointerToThis; } _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users