<?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[struct auf heap erstellen]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe eine (wahrscheinlich) simple Frage.<br />
Ich möchte einen struct auf dem Heap erstellen.</p>
<pre><code class="language-cpp">struct test {
int i,
int j
};
</code></pre>
<p>Muss ich in dem Fall erst das Objekt erzeugen und dann alle Werte<br />
einzeln initialisieren?</p>
<pre><code class="language-cpp">test* t = new test;
t.i = 5;
t.j = 6
</code></pre>
<p>oder gibt es eine äquivalente Schreibweise zur Erstellung auf dem Stack?</p>
<pre><code class="language-cpp">test t = {5,6};
</code></pre>
<p>Gruß,<br />
*Cpp-Anfänger*</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/244413/struct-auf-heap-erstellen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 19 Sep 2026 10:49:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/244413.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 Jun 2009 23:30:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to struct auf heap erstellen on Mon, 29 Jun 2009 23:30:52 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe eine (wahrscheinlich) simple Frage.<br />
Ich möchte einen struct auf dem Heap erstellen.</p>
<pre><code class="language-cpp">struct test {
int i,
int j
};
</code></pre>
<p>Muss ich in dem Fall erst das Objekt erzeugen und dann alle Werte<br />
einzeln initialisieren?</p>
<pre><code class="language-cpp">test* t = new test;
t.i = 5;
t.j = 6
</code></pre>
<p>oder gibt es eine äquivalente Schreibweise zur Erstellung auf dem Stack?</p>
<pre><code class="language-cpp">test t = {5,6};
</code></pre>
<p>Gruß,<br />
*Cpp-Anfänger*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1734816</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1734816</guid><dc:creator><![CDATA[*Cpp-Anfänger* 0]]></dc:creator><pubDate>Mon, 29 Jun 2009 23:30:52 GMT</pubDate></item><item><title><![CDATA[Reply to struct auf heap erstellen on Tue, 30 Jun 2009 00:06:43 GMT]]></title><description><![CDATA[<p>In C++ kannst du für structs auch Konstruktoren bauen:</p>
<pre><code class="language-cpp">struct MyStruct
{
    int i;

    MyStruct(int i) : i(i) {}
};

MyStruct* myStruct = new MyStruct(5);
cout &lt;&lt; myStruct-&gt;i;
</code></pre>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1734818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1734818</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Tue, 30 Jun 2009 00:06:43 GMT</pubDate></item><item><title><![CDATA[Reply to struct auf heap erstellen on Tue, 30 Jun 2009 00:15:36 GMT]]></title><description><![CDATA[<p>thx!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1734820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1734820</guid><dc:creator><![CDATA[*Cpp-Anfänger* 0]]></dc:creator><pubDate>Tue, 30 Jun 2009 00:15:36 GMT</pubDate></item></channel></rss>