<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hello,<div><br></div><div>You can use just about any object type for a default parameter, and pass parameters to the constructor too.</div><div><br></div><div>You want to be very careful with constructor with only one parameter especial just an integer. A constructor with just one parameter can be used for implicit conversion. Add the "explicit" keyword before to prevent this:</div><div><br></div><div>class A {</div><div> explicit A(int A, PointerType ptr = NULL )</div><div>};</div><div><br></div><div>And that takes advantage of the implicit conversion with the smart pointer constructor.</div><div><br></div><div>Hope that help,</div><div>Brad</div><div><br><div><div>On Jul 22, 2014, at 4:49 AM, vincent ngai <<a href="mailto:vincent.ngai@gmail.com">vincent.ngai@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr">Technically it should be <span style="font-family:arial,sans-serif;font-size:13px">A(int a, ImageType::Pointer ptr = ImageType::Pointer() );</span><div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">But I"m not sure if parameter defaults are supported on non-POD parameter types. Why not just overload the ctor and create another </span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">class A</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">{</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"> A(int a, ImageType::Pointer ptr);</span><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"> A( int a );</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">};</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Jul 22, 2014 at 3:37 PM, <span dir="ltr"><<a href="mailto:ahmed@mufradat.com" target="_blank">ahmed@mufradat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello All,<br>
<br>
Suppose I have class like<br>
<br>
class A{<br>
public:<br>
A(int a, ImageType::Pointer ptr){<br>
// whatever!<br>
}<br>
};<br>
<br>
My question is, what's the default value for that ptr? I'd like to be able to create an instance of that class using<br>
<br>
A myA(5);<br>
<br>
so for the definition of the constructor of A:<br>
<br>
A(int a, ImageType::Pointer ptr = WHAT?)<br>
<br>
Best regards,<br>
Ahmed<br>
______________________________<u></u>_______<br>
Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/<u></u>products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_<u></u>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/<u></u>mailman/listinfo/insight-users</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>Vincent<br>
</div>
_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://public.kitware.com/mailman/listinfo/insight-users<br>_______________________________________________<br>Community mailing list<br>Community@itk.org<br>http://public.kitware.com/mailman/listinfo/community<br></blockquote></div><br></div></body></html>