<?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[Konstruktor~Destruktor]]></title><description><![CDATA[<p>Hallo liebe C++ Experten,<br />
Ich habe hier ein einfaches c++ Programm:</p>
<pre><code>#include&lt;iostream&gt;
using namespace std;

class test{
private:
int abc;
public:
test(int i=9);    //Konstruktor
~test();          //Destruktor
int ausgabe() {return abc;}
};
test::test(int i) {    //Konstruktor
cout&lt;&lt;&quot;Konstruktor\n&quot;;
if (i&gt;12)
abc=i;
else
abc=i;
}

test::~test(){        //Destruktor
cout&lt;&lt;&quot;Destruktor\n&quot;;
};

int main() {
test x(7);
test y;
test z(13);
cout&lt;&lt;&quot; &quot;&lt;&lt;x.ausgabe()&lt;&lt;&quot;\n&quot;;
cout&lt;&lt;&quot; &quot;&lt;&lt;y.ausgabe()&lt;&lt;&quot;\n&quot;;
cout&lt;&lt;&quot; &quot;&lt;&lt;z.ausgabe()&lt;&lt;&quot;\n&quot;;

return 0;
}
</code></pre>
<p>:<br />
unter Linux kommt einwandfrei:</p>
<pre><code>Konstruktor
Konstruktor
Konstruktor
 7
 9
 13
Destruktor
Destruktor
Destruktor
</code></pre>
<p>unter Windows bekomme Ich bei demselben Programm unter Dev++ leider nur:</p>
<pre><code>Konstruktor
Konstruktor
Konstruktor
 7
 9
 13
</code></pre>
<p>???</p>
<p>Warum fehlt der Destruktordurchlauf, hat jemand eine Idee ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/327653/konstruktor-destruktor</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Jul 2026 14:30:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/327653.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Aug 2014 12:23:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Konstruktor~Destruktor on Mon, 25 Aug 2014 12:23:29 GMT]]></title><description><![CDATA[<p>Hallo liebe C++ Experten,<br />
Ich habe hier ein einfaches c++ Programm:</p>
<pre><code>#include&lt;iostream&gt;
using namespace std;

class test{
private:
int abc;
public:
test(int i=9);    //Konstruktor
~test();          //Destruktor
int ausgabe() {return abc;}
};
test::test(int i) {    //Konstruktor
cout&lt;&lt;&quot;Konstruktor\n&quot;;
if (i&gt;12)
abc=i;
else
abc=i;
}

test::~test(){        //Destruktor
cout&lt;&lt;&quot;Destruktor\n&quot;;
};

int main() {
test x(7);
test y;
test z(13);
cout&lt;&lt;&quot; &quot;&lt;&lt;x.ausgabe()&lt;&lt;&quot;\n&quot;;
cout&lt;&lt;&quot; &quot;&lt;&lt;y.ausgabe()&lt;&lt;&quot;\n&quot;;
cout&lt;&lt;&quot; &quot;&lt;&lt;z.ausgabe()&lt;&lt;&quot;\n&quot;;

return 0;
}
</code></pre>
<p>:<br />
unter Linux kommt einwandfrei:</p>
<pre><code>Konstruktor
Konstruktor
Konstruktor
 7
 9
 13
Destruktor
Destruktor
Destruktor
</code></pre>
<p>unter Windows bekomme Ich bei demselben Programm unter Dev++ leider nur:</p>
<pre><code>Konstruktor
Konstruktor
Konstruktor
 7
 9
 13
</code></pre>
<p>???</p>
<p>Warum fehlt der Destruktordurchlauf, hat jemand eine Idee ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414841</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414841</guid><dc:creator><![CDATA[softpad]]></dc:creator><pubDate>Mon, 25 Aug 2014 12:23:29 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Mon, 25 Aug 2014 12:35:46 GMT]]></title><description><![CDATA[<p>Fehlt der Aufruf oder nur die Ausgabe?<br />
- versuche es mit cerr statt cout<br />
- benutze einen Debugger</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414842</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414842</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 25 Aug 2014 12:35:46 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Mon, 25 Aug 2014 12:49:59 GMT]]></title><description><![CDATA[<p>vs 2013 (v120), ctp nov 2013, icc xe 14:</p>
<pre><code>Konstruktor
Konstruktor
Konstruktor
 7
 9
 13
Destruktor
Destruktor
Destruktor
</code></pre>
<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414845</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414845</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Mon, 25 Aug 2014 12:49:59 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Mon, 25 Aug 2014 13:00:47 GMT]]></title><description><![CDATA[<p>wenn Ich in Zeile 21 cerr statt cout eingebe geht es auch nicht ..? Aber es kommen keine Fehlermeldungen, deshalb glaube Ich, dass der Aufruf funktioniert ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414848</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414848</guid><dc:creator><![CDATA[softpad]]></dc:creator><pubDate>Mon, 25 Aug 2014 13:00:47 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Mon, 25 Aug 2014 13:12:47 GMT]]></title><description><![CDATA[<p>Hi versuch es mal mit</p>
<pre><code>#include&lt;iostream&gt; 
using namespace std; 

class test{ 
private: 
int abc; 
public: 
test(int i=9);    //Konstruktor 
~test();          //Destruktor 
int ausgabe() {return abc;} 
}; 
test::test(int i) {    //Konstruktor 
cout&lt;&lt;&quot;Konstruktor\n&quot;; 
if (i&gt;12) 
abc=i; 
else 
abc=i; 
} 

test::~test(){        //Destruktor 
cout&lt;&lt;&quot;Destruktor\n&quot;; 
};

void testfunc()
{
 test x(7); 
 test y; 
 test z(13); 
 cout&lt;&lt;&quot; &quot;&lt;&lt;x.ausgabe()&lt;&lt;&quot;\n&quot;; 
 cout&lt;&lt;&quot; &quot;&lt;&lt;y.ausgabe()&lt;&lt;&quot;\n&quot;; 
 cout&lt;&lt;&quot; &quot;&lt;&lt;z.ausgabe()&lt;&lt;&quot;\n&quot;;
}

int main() { 
 testfunc();

return 0; 
}
</code></pre>
<p>ich glaube die Ausgabe wird nicht mehr richtig über cout und cerr ausgegeben nach dem Programmende. Vieleicht muss man sie auch einfach nur flushen oder so?</p>
<p>Gruß, Daniel_S</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414850</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Mon, 25 Aug 2014 13:12:47 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Mon, 25 Aug 2014 13:27:11 GMT]]></title><description><![CDATA[<p>jetzt geht es auch in cpp super! danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414852</guid><dc:creator><![CDATA[softpad]]></dc:creator><pubDate>Mon, 25 Aug 2014 13:27:11 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Mon, 25 Aug 2014 13:28:12 GMT]]></title><description><![CDATA[<p>Daniel_S schrieb:</p>
<blockquote>
<p>ich glaube die Ausgabe wird nicht mehr richtig über cout und cerr ausgegeben <strong>nach dem Programmende.</strong></p>
</blockquote>
<p>Nene:</p>
<p>ISO/IEC 14882:2011 (N3777) schrieb:</p>
<blockquote>
<p>§ 3.7.3.3<br />
If a variable with automatic storage duration has initialization or a destructor with side effects, it <strong>shall not be destroyed before the end of its block, nor shall it be eliminated as an optimization even if it appears to be unused</strong>, except that a class object or its copy/move may be eliminated as specified in 12.8.</p>
</blockquote>
<p>//edith: Darf doch nicht sein, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414853</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414853</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Mon, 25 Aug 2014 13:28:12 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Mon, 25 Aug 2014 19:08:40 GMT]]></title><description><![CDATA[<blockquote>
<p>ISO/IEC 14882:2011 (N3777)</p>
</blockquote>
<p>N3337 reicht.</p>
<blockquote>
<p>Darf doch nicht sein, oder?</p>
</blockquote>
<p>Was genau darf nicht sein? Das Zitat ist selbstverständlich. Vergiss aber nicht as-if. Solange keine beobachtbaren Seiteneffekte verändert werden kann die Implementierung optimieren wie sie lustig ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414888</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 25 Aug 2014 19:08:40 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Mon, 25 Aug 2014 20:45:52 GMT]]></title><description><![CDATA[<p>Wie waere es, wenn du deinen Code erstmal formatierst. Kann (/will) ja niemand lesen so.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414894</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414894</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Mon, 25 Aug 2014 20:45:52 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Mon, 25 Aug 2014 22:22:48 GMT]]></title><description><![CDATA[<p>Hier hat jemand das selbe Problem <a href="http://stackoverflow.com/questions/6494278/destructor-does-not-work" rel="nofollow">http://stackoverflow.com/questions/6494278/destructor-does-not-work</a></p>
<p>Hast du dein Programm (die erste Version) mal aus der Konsole gestartet wie im Link beschrieben, oder nur so per Doppelklick?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414910</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414910</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Mon, 25 Aug 2014 22:22:48 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Tue, 26 Aug 2014 03:08:23 GMT]]></title><description><![CDATA[<p>Arcoth schrieb:</p>
<blockquote>
<blockquote>
<p>ISO/IEC 14882:2011 (N3777)</p>
</blockquote>
<p>N3337 reicht.</p>
</blockquote>
<p>Sag mir bitte nicht, was ich schreiben darf und was nicht ...</p>
<p>Arcoth schrieb:</p>
<blockquote>
<blockquote>
<p>Darf doch nicht sein, oder?</p>
</blockquote>
<p>Was genau darf nicht sein? [...] Vergiss aber nicht as-if. [...]</p>
</blockquote>
<p>Das, was der TO beschreibt. Das ist nicht as-if. Aber wahrscheinlich hat er einfach nur die Testumstände ungenau beschrieben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414920</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414920</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Tue, 26 Aug 2014 03:08:23 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Tue, 26 Aug 2014 05:11:04 GMT]]></title><description><![CDATA[<p>Arcoth schrieb:</p>
<blockquote>
<blockquote>
<p>ISO/IEC 14882:2011 (N3777)</p>
</blockquote>
<p>N3337 reicht.</p>
</blockquote>
<p>Aber mit der Lang-Version kann ein Einsteiger doch echt besser selber danach googeln. Sehr fein von Swordfish, die manchmal auch zu nennen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414926</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414926</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Tue, 26 Aug 2014 05:11:04 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Tue, 26 Aug 2014 06:41:37 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Arcoth schrieb:</p>
<blockquote>
<blockquote>
<p>ISO/IEC 14882:2011 (N3777)</p>
</blockquote>
<p>N3337 reicht.</p>
</blockquote>
<p>Aber mit der Lang-Version kann ein Einsteiger doch echt besser selber danach googeln.</p>
</blockquote>
<p>N3337 reicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Swordfish schrieb:</p>
<blockquote>
<p>Arcoth schrieb:</p>
<blockquote>
<blockquote>
<p>ISO/IEC 14882:2011 (N3777)</p>
</blockquote>
<p>N3337 reicht.</p>
</blockquote>
<p>Sag mir bitte nicht, was ich schreiben darf und was nicht ...</p>
</blockquote>
<p>Er hat doch nur geschrieben dass N3337 reicht. Ist doch kein &quot;Verbot&quot; es auszuschreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414930</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414930</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 26 Aug 2014 06:41:37 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor~Destruktor on Tue, 26 Aug 2014 07:19:54 GMT]]></title><description><![CDATA[<blockquote>
<p>Das, was der TO beschreibt.</p>
</blockquote>
<p>Achso, ich dachte du meinst das Zitat. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414935</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414935</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Tue, 26 Aug 2014 07:19:54 GMT</pubDate></item></channel></rss>