<div dir="ltr">Thanks for the reply.&nbsp; 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?&nbsp; <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&#39;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">&lt;<a href="mailto:boost.lists@gmail.com">boost.lists@gmail.com</a>&gt;</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">&gt; TextTool::TextTool(QDialog *taskDialogue) : Tool(this-&gt;name)<br>
&gt; {<br>
&gt; &nbsp; &nbsp; boost::shared_ptr&lt;TextTool&gt; pointerToThis =<br>
&gt; TextTool::shared_from_this(); &nbsp;//ERROR OCCURS ON THIS LINE<br>
&gt;<br>
&gt; &nbsp; &nbsp; bold = boost::shared_ptr&lt;ToggleControl&gt;(new<br>
&gt; ToggleControl(pointerToThis));<br>
&gt; }<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&lt;TextTool&gt; TextTool::create(QDialog *taskDialogue)<br>
{<br>
 &nbsp;boost::shared_ptr&lt;TextTool&gt; pointerToThis(new TextTool(taskDialogue));<br>
 &nbsp;pointerToThis-&gt;bold.reset(new ToggleControl(pointerToThis));<br>
 &nbsp;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>