<?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[Zeiger auf Zeiger - Ausgabe - warum?]]></title><description><![CDATA[<p>Moin!<br />
Ich habe folgendes Verständnisproblem.</p>
<p>Soweit ich das unten stehende Programm verstehe lege ich mit</p>
<pre><code class="language-cpp">int***stack1
</code></pre>
<p>ein stack objekt mit 3 aufeinander folgenden heap-objekten.</p>
<p>quasi so: stack1 ***objekt -&gt; **heap1 -&gt; **heap2 -&gt; heap3</p>
<p>stack2: stack2* objekt -&gt; heap1</p>
<p>Durch</p>
<pre><code class="language-cpp">*stack1=&amp;stack2;
</code></pre>
<p>zeigt nun das 1. heapObjekt von stack1 auf das stackObjekt stack2.</p>
<p>Sehe ich das soweit richtig?</p>
<p>Nun zum eigentlichen &quot;Problem&quot;:</p>
<p>Warum bekomme ich an der von mir mit &quot; // &lt;&lt;&lt;&quot; gekennzeichneten stelle eine 40 ausgegeben?</p>
<pre><code class="language-cpp">void main()
{
	int***stack1;
	int*stack2;

	stack1=new int**;
	stack2=new int;

	*stack1=&amp;stack2;
	*stack2=40;

	cout &lt;&lt;  stack1 &lt;&lt; endl;
	cout &lt;&lt;  *stack1 &lt;&lt; endl;
	cout &lt;&lt;  **stack1 &lt;&lt; endl;
	cout &lt;&lt;  ***stack1 &lt;&lt; endl; // &lt;&lt;&lt;
	cout &lt;&lt;  stack2 &lt;&lt; endl;
	cout &lt;&lt;  *stack2 &lt;&lt; endl &lt;&lt; endl;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/270061/zeiger-auf-zeiger-ausgabe-warum</link><generator>RSS for Node</generator><lastBuildDate>Sun, 30 Aug 2026 16:52:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/270061.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Jul 2010 23:47:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zeiger auf Zeiger - Ausgabe - warum? on Mon, 05 Jul 2010 23:47:10 GMT]]></title><description><![CDATA[<p>Moin!<br />
Ich habe folgendes Verständnisproblem.</p>
<p>Soweit ich das unten stehende Programm verstehe lege ich mit</p>
<pre><code class="language-cpp">int***stack1
</code></pre>
<p>ein stack objekt mit 3 aufeinander folgenden heap-objekten.</p>
<p>quasi so: stack1 ***objekt -&gt; **heap1 -&gt; **heap2 -&gt; heap3</p>
<p>stack2: stack2* objekt -&gt; heap1</p>
<p>Durch</p>
<pre><code class="language-cpp">*stack1=&amp;stack2;
</code></pre>
<p>zeigt nun das 1. heapObjekt von stack1 auf das stackObjekt stack2.</p>
<p>Sehe ich das soweit richtig?</p>
<p>Nun zum eigentlichen &quot;Problem&quot;:</p>
<p>Warum bekomme ich an der von mir mit &quot; // &lt;&lt;&lt;&quot; gekennzeichneten stelle eine 40 ausgegeben?</p>
<pre><code class="language-cpp">void main()
{
	int***stack1;
	int*stack2;

	stack1=new int**;
	stack2=new int;

	*stack1=&amp;stack2;
	*stack2=40;

	cout &lt;&lt;  stack1 &lt;&lt; endl;
	cout &lt;&lt;  *stack1 &lt;&lt; endl;
	cout &lt;&lt;  **stack1 &lt;&lt; endl;
	cout &lt;&lt;  ***stack1 &lt;&lt; endl; // &lt;&lt;&lt;
	cout &lt;&lt;  stack2 &lt;&lt; endl;
	cout &lt;&lt;  *stack2 &lt;&lt; endl &lt;&lt; endl;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1922014</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922014</guid><dc:creator><![CDATA[DennisM]]></dc:creator><pubDate>Mon, 05 Jul 2010 23:47:10 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger auf Zeiger - Ausgabe - warum? on Mon, 05 Jul 2010 23:53:19 GMT]]></title><description><![CDATA[<p>Naja, wenn *stack1 == &amp;stack2 ist, ist **stack1 == stack2 und ***stack1 == *stack2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922016</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922016</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Mon, 05 Jul 2010 23:53:19 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger auf Zeiger - Ausgabe - warum? on Tue, 06 Jul 2010 00:09:48 GMT]]></title><description><![CDATA[<p>Danke für deine sehr rasche Antwort (zu solch später Stunde)...<br />
Doch trotzdem ist es mir nicht so ganz klar.</p>
<p>wenn *stack1 == &amp;stack2 ist,&quot; // klar</p>
<p>ist **stack1 == stack2 // warum? ich sage doch nur explizit das *stack1 auf stack 2 zeigen soll und nicht dass **stack1 auf stack2 zeigt...</p>
<p>und ***stack1 == *stack2. // - &quot; -</p>
<p>Es ist warscheinlich sehr simpel aber irendwie habe ich wohl eine Blockade.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922019</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922019</guid><dc:creator><![CDATA[DennisM]]></dc:creator><pubDate>Tue, 06 Jul 2010 00:09:48 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger auf Zeiger - Ausgabe - warum? on Tue, 06 Jul 2010 04:08:31 GMT]]></title><description><![CDATA[<blockquote>
<p>und nicht dass **stack1 auf stack2 zeigt...</p>
</blockquote>
<p>**stack1 zeigt ja auch nicht auf stack2, sondern auf die 40.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922027</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922027</guid><dc:creator><![CDATA[Athar]]></dc:creator><pubDate>Tue, 06 Jul 2010 04:08:31 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger auf Zeiger - Ausgabe - warum? on Tue, 06 Jul 2010 09:55:23 GMT]]></title><description><![CDATA[<blockquote>
<p>Soweit ich das unten stehende Programm verstehe lege ich mit<br />
C/C++ Code:</p>
<pre><code class="language-cpp">int***stack1
</code></pre>
<p>ein stack objekt mit 3 aufeinander folgenden heap-objekten.</p>
<p>quasi so: stack1 ***objekt -&gt; **heap1 -&gt; **heap2 -&gt; heap3</p>
</blockquote>
<p>Nein...</p>
<p>Du legst gar nichts an. Du Deklarierst nur einen Zeiger auf einen Zeiger auf einen Zeiger auf einen int.</p>
<pre><code class="language-cpp">stack1=new int**;
</code></pre>
<p>In dieser Zeile legst du einen(!) Zeiger auf dem Heap an.[1]<br />
Es ist ein Zeiger auf einen Zeiger auf ein int.<br />
Deine Variable stack1 zeigt nun auf diesen Speicherbereich.</p>
<pre><code class="language-cpp">stack2=new int;
</code></pre>
<p>Hier erstellst du ein int [2] auf dem<br />
stack2 verweist nun auf diesen int.</p>
<pre><code class="language-cpp">*stack1=&amp;stack2;
</code></pre>
<p>Hier dereferenzierst du dein stack1 und änderst dadurch den Speicherbereich<br />
für [1]. Dieser zeigt nun auf die Speicheradresse des Zeigers stack2.<br />
Das ist eine Stackadresse!!</p>
<pre><code class="language-cpp">*stack2=40;
</code></pre>
<p>Hier dereferenzierst du den Zeiger stack2 und veränderst damit den Inhalt<br />
von [2]</p>
<p>Am Ende hast du dann sowas:</p>
<blockquote>
<p>stack1(Stack) -&gt; [1](Heap) -&gt; stack2(Stack) -&gt; [2] mit Wert 40(Heap)</p>
</blockquote>
<p>Gruß,<br />
CSpille</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922093</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922093</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 06 Jul 2010 09:55:23 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger auf Zeiger - Ausgabe - warum? on Tue, 06 Jul 2010 09:47:12 GMT]]></title><description><![CDATA[<p>Ah!<br />
Na das macht doch Sinn! Vielen Dank für die ausführliche Erklärung!</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1922119</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1922119</guid><dc:creator><![CDATA[DennisM]]></dc:creator><pubDate>Tue, 06 Jul 2010 09:47:12 GMT</pubDate></item></channel></rss>