<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[About default constructor]]></title><description><![CDATA[<p dir="auto">@<br />
class A {<br />
public:<br />
A(int x = 0) { v = x; }<br />
private:<br />
int v;<br />
};<br />
@</p>
<p dir="auto">The definition for default constructor: "The constructor that takes no arguments is known as the default constructor."<br />
Is A(int x = 0); a default constructor?</p>
]]></description><link>https://forum.qt.io/topic/8001/about-default-constructor</link><generator>RSS for Node</generator><lastBuildDate>Tue, 16 Jun 2026 11:33:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/8001.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 27 Jul 2011 15:16:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to About default constructor on Mon, 08 Aug 2011 10:51:12 GMT]]></title><description><![CDATA[<p dir="auto">The C++ standard is very clear about what a default constructor is (section 12.1, number 5):</p>
<p dir="auto">[quote]<br />
A default constructor for a class X is a constructor of class X that can be called without an argument. If there is no user-declared constructor for class X, a default constructor is implicitly declared. [...]<br />
[/quote]</p>
]]></description><link>https://forum.qt.io/post/103950</link><guid isPermaLink="true">https://forum.qt.io/post/103950</guid><dc:creator><![CDATA[goetz]]></dc:creator><pubDate>Mon, 08 Aug 2011 10:51:12 GMT</pubDate></item><item><title><![CDATA[Reply to About default constructor on Mon, 08 Aug 2011 10:28:49 GMT]]></title><description><![CDATA[<p dir="auto">it's just a defination...the default constructor is always one without parameters (included optional parameters)</p>
]]></description><link>https://forum.qt.io/post/103947</link><guid isPermaLink="true">https://forum.qt.io/post/103947</guid><dc:creator><![CDATA[AlterX]]></dc:creator><pubDate>Mon, 08 Aug 2011 10:28:49 GMT</pubDate></item><item><title><![CDATA[Reply to About default constructor on Thu, 28 Jul 2011 07:11:27 GMT]]></title><description><![CDATA[<p dir="auto">bq. You can test it yourself. Put a debug in the constructor. Create an instance of A and see if your constructor is called or not.</p>
<p dir="auto">The <em><em>practical</em></em> meaning of a default constructor is that if you don't define one yourself the compiler is making one implicitly for you.</p>
<p dir="auto">Have a look at this example :</p>
<p dir="auto">@class A { public:<br />
//A(int x = 0) { v = x; cout &lt;&lt; " test my constructor";}    //just for later use<br />
private:<br />
int v;<br />
}; @</p>
<p dir="auto">So for instance when you use class A in another class B, the default constructor, implicitly created by the compiler, will be called.</p>
<p dir="auto">@class B { public:<br />
private:<br />
A a;<br />
}; @</p>
<p dir="auto">If you uncomment line 2 of class A, you will see the cout message, meaning your constructor is called with no parameter. Thus it's a default constructor. And you as a programmer took control over it.</p>
<p dir="auto">In this example there is no practical need to define one since the result of both will be te same. Of course in real life things aren't that simple ;)</p>
]]></description><link>https://forum.qt.io/post/102304</link><guid isPermaLink="true">https://forum.qt.io/post/102304</guid><dc:creator><![CDATA[Eddy]]></dc:creator><pubDate>Thu, 28 Jul 2011 07:11:27 GMT</pubDate></item><item><title><![CDATA[Reply to About default constructor on Thu, 28 Jul 2011 02:16:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/a">@<bdi>A</bdi></a>(int x = 0) @<br />
is a default constructor with the default argument.</p>
<p dir="auto">if <a class="plugin-mentions-user plugin-mentions-a" href="/user/a">@<bdi>A</bdi></a>(int x)@ without default argument, it's not a default constructor</p>
]]></description><link>https://forum.qt.io/post/102277</link><guid isPermaLink="true">https://forum.qt.io/post/102277</guid><dc:creator><![CDATA[Chuck Gao]]></dc:creator><pubDate>Thu, 28 Jul 2011 02:16:11 GMT</pubDate></item><item><title><![CDATA[Reply to About default constructor on Wed, 27 Jul 2011 20:40:47 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="Edico" date="1311779819"]The definition for default constructor: "The constructor that takes no arguments is known as the default constructor."[/quote]</p>
<p dir="auto">The definition is wrong.</p>
<p dir="auto"><a href="http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.4" target="_blank" rel="noopener noreferrer nofollow ugc">http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.4</a></p>
]]></description><link>https://forum.qt.io/post/102238</link><guid isPermaLink="true">https://forum.qt.io/post/102238</guid><dc:creator><![CDATA[dangelog]]></dc:creator><pubDate>Wed, 27 Jul 2011 20:40:47 GMT</pubDate></item><item><title><![CDATA[Reply to About default constructor on Wed, 27 Jul 2011 18:51:40 GMT]]></title><description><![CDATA[<p dir="auto">It is a default constuictor as the argument is optional.</p>
]]></description><link>https://forum.qt.io/post/102207</link><guid isPermaLink="true">https://forum.qt.io/post/102207</guid><dc:creator><![CDATA[giesbert]]></dc:creator><pubDate>Wed, 27 Jul 2011 18:51:40 GMT</pubDate></item><item><title><![CDATA[Reply to About default constructor on Wed, 27 Jul 2011 18:18:53 GMT]]></title><description><![CDATA[<p dir="auto">bq.<br />
"ISO/IEC 14882:2003, 12.1.5":<a href="http://cs.nyu.edu/courses/summer11/G22.2110-001/documents/c++2003std.pdf" target="_blank" rel="noopener noreferrer nofollow ugc">http://cs.nyu.edu/courses/summer11/G22.2110-001/documents/c++2003std.pdf</a> A <em>default constructor</em> for a class X is a constructor of class X <em>that can be called without an argument</em>. If there is no user-declared constructor for class X, a default constructor is implicitly declared.</p>
<p dir="auto">[quote author="Edico" date="1311779819"]Is A(int x = 0); a default constructor?[/quote]</p>
<p dir="auto">Yes.</p>
]]></description><link>https://forum.qt.io/post/102198</link><guid isPermaLink="true">https://forum.qt.io/post/102198</guid><dc:creator><![CDATA[lgeyer]]></dc:creator><pubDate>Wed, 27 Jul 2011 18:18:53 GMT</pubDate></item><item><title><![CDATA[Reply to About default constructor on Wed, 27 Jul 2011 15:46:50 GMT]]></title><description><![CDATA[<p dir="auto">You can test it yourself. Put a debug in the constructor. Create an instance of A and see if your constructor is called or not.</p>
]]></description><link>https://forum.qt.io/post/102177</link><guid isPermaLink="true">https://forum.qt.io/post/102177</guid><dc:creator><![CDATA[Eddy]]></dc:creator><pubDate>Wed, 27 Jul 2011 15:46:50 GMT</pubDate></item><item><title><![CDATA[Reply to About default constructor on Wed, 27 Jul 2011 15:38:07 GMT]]></title><description><![CDATA[<p dir="auto">As you just said, “The constructor that takes no arguments is known as the default constructor.”<br />
The A(int x = 0) constructor takes int x as an argument, so no, it isn't a default constructor. The default constructor would be<br />
@class A {<br />
public:<br />
A();<br />
...<br />
@</p>
]]></description><link>https://forum.qt.io/post/102174</link><guid isPermaLink="true">https://forum.qt.io/post/102174</guid><dc:creator><![CDATA[HuXiKa]]></dc:creator><pubDate>Wed, 27 Jul 2011 15:38:07 GMT</pubDate></item></channel></rss>