<?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[Anwendung von tr1::array]]></title><description><![CDATA[<p>Ich werde nicht schlau aus dem neuen Array.</p>
<p>Ich habe folgenden Code</p>
<pre><code class="language-cpp">class A{
 private:
  gl_tex *texptr;
 public:
  void render_tex();
}
A::render_tex(){
...
gl_tex = new bool[n]
...
}
</code></pre>
<p>n ist ein integer und wird dynamisch festgelegt.<br />
Ich möchte es am besten durch array ersetzen aber irgendwie verlangt er von mir immer noch eine Größe.</p>
<p>Ich möchte mir das array aneignen weil ich nicht später selber den Speicher freigeben muss weil ich noch als Anfänger zu viele leaks verursache die schwer zu finden sind. Kann ich das array auf mein Problem anwenden? Wie würde der code aussehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/271690/anwendung-von-tr1-array</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 07:22:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/271690.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Aug 2010 12:29:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 12:29:29 GMT]]></title><description><![CDATA[<p>Ich werde nicht schlau aus dem neuen Array.</p>
<p>Ich habe folgenden Code</p>
<pre><code class="language-cpp">class A{
 private:
  gl_tex *texptr;
 public:
  void render_tex();
}
A::render_tex(){
...
gl_tex = new bool[n]
...
}
</code></pre>
<p>n ist ein integer und wird dynamisch festgelegt.<br />
Ich möchte es am besten durch array ersetzen aber irgendwie verlangt er von mir immer noch eine Größe.</p>
<p>Ich möchte mir das array aneignen weil ich nicht später selber den Speicher freigeben muss weil ich noch als Anfänger zu viele leaks verursache die schwer zu finden sind. Kann ich das array auf mein Problem anwenden? Wie würde der code aussehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935139</guid><dc:creator><![CDATA[tr1__array]]></dc:creator><pubDate>Mon, 02 Aug 2010 12:29:29 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 12:35:14 GMT]]></title><description><![CDATA[<p>Wenn du ein dynamisches Array haben möchtest muss du std::vector&lt;&gt; nehmen.</p>
<p>std::array&lt;typ, groeße&gt; verlangt eine Konstante als Größe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935141</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935141</guid><dc:creator><![CDATA[Roger Wilco]]></dc:creator><pubDate>Mon, 02 Aug 2010 12:35:14 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 14:06:12 GMT]]></title><description><![CDATA[<p>Roger Wilco schrieb:</p>
<blockquote>
<p>Wenn du ein dynamisches Array haben möchtest muss du std::vector&lt;&gt; nehmen.</p>
<p>std::array&lt;typ, groeße&gt; verlangt eine Konstante als Größe.</p>
</blockquote>
<p>Gibt es eine Möglichkeit alle Elemente eines Vektors auf Null zu setzen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935179</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935179</guid><dc:creator><![CDATA[tr1__array]]></dc:creator><pubDate>Mon, 02 Aug 2010 14:06:12 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 14:17:39 GMT]]></title><description><![CDATA[<p>std::fill</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935190</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935190</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Mon, 02 Aug 2010 14:17:39 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 14:19:00 GMT]]></title><description><![CDATA[<p>Wie wäre es mal, wenn du dir einfach mal die vector-Klasse anschaust? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p><a href="http://www.cplusplus.com/reference/stl/vector/vector/" rel="nofollow">http://www.cplusplus.com/reference/stl/vector/vector/</a></p>
<pre><code class="language-cpp">std::vector&lt;bool&gt; v(n, false); // n-Elemente, mit false vorbelegen
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1935192</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935192</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Mon, 02 Aug 2010 14:19:00 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 14:42:40 GMT]]></title><description><![CDATA[<p>Artchi schrieb:</p>
<blockquote>
<p>Wie wäre es mal, wenn du dir einfach mal die vector-Klasse anschaust? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p><a href="http://www.cplusplus.com/reference/stl/vector/vector/" rel="nofollow">http://www.cplusplus.com/reference/stl/vector/vector/</a></p>
<pre><code class="language-cpp">std::vector&lt;bool&gt; v(n, false); // n-Elemente, mit false vorbelegen
</code></pre>
</blockquote>
<p>Wird es auch im Nachhinein funktionieren?<br />
Sonst mache ich sowas bei arrays mit memset</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935204</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935204</guid><dc:creator><![CDATA[tr1__array]]></dc:creator><pubDate>Mon, 02 Aug 2010 14:42:40 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 14:45:46 GMT]]></title><description><![CDATA[<p>tr1__array schrieb:</p>
<blockquote>
<p>Wird es auch im Nachhinein funktionieren?</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /> <em><strong>std::fill</strong></em> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935205</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935205</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Mon, 02 Aug 2010 14:45:46 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 14:50:23 GMT]]></title><description><![CDATA[<p>_matze schrieb:</p>
<blockquote>
<p>tr1__array schrieb:</p>
<blockquote>
<p>Wird es auch im Nachhinein funktionieren?</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /> <em><strong>std::fill</strong></em> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /></p>
</blockquote>
<p>ups hatte was überlesen. Danke an alle Antworten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935207</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935207</guid><dc:creator><![CDATA[tr1__array]]></dc:creator><pubDate>Mon, 02 Aug 2010 14:50:23 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 14:54:05 GMT]]></title><description><![CDATA[<p>Artchi schrieb:</p>
<blockquote>
<pre><code class="language-cpp">std::vector&lt;bool&gt; v(n, false); // n-Elemente, mit false vorbelegen
</code></pre>
</blockquote>
<p><code>vector&lt;bool&gt;</code> würde ich nicht benutzen, weil es eine eher weniger gelungene Spezialisierung ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935209</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935209</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Mon, 02 Aug 2010 14:54:05 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 15:21:50 GMT]]></title><description><![CDATA[<p>Michael E. schrieb:</p>
<blockquote>
<p><code>vector&lt;bool&gt;</code> würde ich nicht benutzen, weil es eine eher weniger gelungene Spezialisierung ist.</p>
</blockquote>
<p>Genaueres siehe <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1847.pdf" rel="nofollow">hier</a>.</p>
<p>Leider gibt es in der Standardbibliothek nicht wirklich Alternativen. Möglicherweise ist <code>std::vector&lt;bool&gt;</code> sogar akzeptabel, wenn die spezielle Semantik einen nicht behindert. Ansonsten könnte man als einfachen Workaround eine Struktur mit einem <code>bool</code> -Member in Betracht ziehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935223</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935223</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Mon, 02 Aug 2010 15:21:50 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung von tr1::array on Mon, 02 Aug 2010 16:50:55 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>Michael E. schrieb:</p>
<blockquote>
<p><code>vector&lt;bool&gt;</code> würde ich nicht benutzen, weil es eine eher weniger gelungene Spezialisierung ist.</p>
</blockquote>
<p>Genaueres siehe <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1847.pdf" rel="nofollow">hier</a>.</p>
<p>Leider gibt es in der Standardbibliothek nicht wirklich Alternativen. Möglicherweise ist <code>std::vector&lt;bool&gt;</code> sogar akzeptabel, wenn die spezielle Semantik einen nicht behindert. Ansonsten könnte man als einfachen Workaround eine Struktur mit einem <code>bool</code> -Member in Betracht ziehen.</p>
</blockquote>
<p>Ich nehme meistens einfach <code>vector&lt;char&gt;</code> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935261</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 02 Aug 2010 16:50:55 GMT</pubDate></item></channel></rss>