<div dir="ltr">Thanks for the reply. But I am still unsure where I should invoke this static method.<br><br>1) I need the member variables initialized...and if I cant do it in the constructor, then where should I? <br>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.<br> <br>Thanks,<br>/C.<br><br><div class="gmail_quote">2008/9/6 Igor R <span dir="ltr"><<a href="mailto:boost.lists@gmail.com">boost.lists@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div class="Ih2E3d">> TextTool::TextTool(QDialog *taskDialogue) : Tool(this->name)<br> > {<br> > boost::shared_ptr<TextTool> pointerToThis =<br> > TextTool::shared_from_this(); //ERROR OCCURS ON THIS LINE<br> ><br> > bold = boost::shared_ptr<ToggleControl>(new<br> > ToggleControl(pointerToThis));<br> > }<br> <br> <br> </div>You cannot call shared_from_this in the constructor. Instead, you can<br> define a static constructing method, like this:<br> <br> // untested!!<br> static boost::shared_ptr<TextTool> TextTool::create(QDialog *taskDialogue)<br> {<br> boost::shared_ptr<TextTool> pointerToThis(new TextTool(taskDialogue));<br> pointerToThis->bold.reset(new ToggleControl(pointerToThis));<br> return pointerToThis;<br> }<br> _______________________________________________<br> Boost-users mailing list<br> <a href="mailto:Boost-users@lists.boost.org">Boost-users@lists.boost.org</a><br> <a href="http://lists.boost.org/mailman/listinfo.cgi/boost-users" target="_blank">http://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br> </blockquote></div><br></div>