<?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[CTypedPtrArray::Add]]></title><description><![CDATA[<p>Hallo Forum,</p>
<p>ich möchte beliebig viele Objekte einer Klasse erzeugen und diese im CTypedPtrArray abspeichern. Dazu habe ich folgendes gemacht:</p>
<p>Membervariable:</p>
<pre><code>CTypedPtrArray &lt; CObArray, CMyClass* &gt; *m_pCMyClasses
</code></pre>
<p>nun erzeuge ich ein paar Objekte und möchte diese in m_pCMyClasses ablegen:</p>
<pre><code>CMyClass *pMyClass = new CMyClass[nIndex];

for(int i=0; i&lt;nIndex; i++)
{
  pMyClass[i].SetSomething(i);
  m_pCMyClass-&gt;Add(pMyClass[i]); 
}
</code></pre>
<p>als Fehlermeldung erhalte ich:</p>
<blockquote>
<p>error C2664: 'CTypedPtrArray&lt;BASE_CLASS,TYPE&gt;::Add': Konvertierung des Parameters 1 von 'CMyClass' in 'CMyClass *' nicht möglich</p>
</blockquote>
<p>Was habe ich falsch gemacht?</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/150635/ctypedptrarray-add</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 13:45:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/150635.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 18 Jun 2006 22:02:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CTypedPtrArray::Add on Sun, 18 Jun 2006 22:02:25 GMT]]></title><description><![CDATA[<p>Hallo Forum,</p>
<p>ich möchte beliebig viele Objekte einer Klasse erzeugen und diese im CTypedPtrArray abspeichern. Dazu habe ich folgendes gemacht:</p>
<p>Membervariable:</p>
<pre><code>CTypedPtrArray &lt; CObArray, CMyClass* &gt; *m_pCMyClasses
</code></pre>
<p>nun erzeuge ich ein paar Objekte und möchte diese in m_pCMyClasses ablegen:</p>
<pre><code>CMyClass *pMyClass = new CMyClass[nIndex];

for(int i=0; i&lt;nIndex; i++)
{
  pMyClass[i].SetSomething(i);
  m_pCMyClass-&gt;Add(pMyClass[i]); 
}
</code></pre>
<p>als Fehlermeldung erhalte ich:</p>
<blockquote>
<p>error C2664: 'CTypedPtrArray&lt;BASE_CLASS,TYPE&gt;::Add': Konvertierung des Parameters 1 von 'CMyClass' in 'CMyClass *' nicht möglich</p>
</blockquote>
<p>Was habe ich falsch gemacht?</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1080304</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1080304</guid><dc:creator><![CDATA[toh]]></dc:creator><pubDate>Sun, 18 Jun 2006 22:02:25 GMT</pubDate></item><item><title><![CDATA[Reply to CTypedPtrArray::Add on Sun, 18 Jun 2006 23:00:30 GMT]]></title><description><![CDATA[<p>Du übergibst bei</p>
<pre><code class="language-cpp">m_pCMyClass-&gt;Add(pMyClass[i]);
</code></pre>
<p>das Objekt. Verlangt wird aber die Adresse (Pointer) des Objektes.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1080311</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1080311</guid><dc:creator><![CDATA[guenni81]]></dc:creator><pubDate>Sun, 18 Jun 2006 23:00:30 GMT</pubDate></item><item><title><![CDATA[Reply to CTypedPtrArray::Add on Mon, 19 Jun 2006 09:53:22 GMT]]></title><description><![CDATA[<p>ja genau.<br />
Wenn ich aber die Adresse übergebe:</p>
<pre><code>m_pCMyClass-&gt;Add(&amp;pMyClass[i]);
</code></pre>
<p>bekomme ich ne andere Fehlermeldung:</p>
<blockquote>
<p>CTypedPtrArray&lt;BASE_CLASS,TYPE&gt;::Add': Konvertierung des Parameters 1 von 'CMyClass *' in 'CObject *' nicht möglich</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1080495</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1080495</guid><dc:creator><![CDATA[toh]]></dc:creator><pubDate>Mon, 19 Jun 2006 09:53:22 GMT</pubDate></item><item><title><![CDATA[Reply to CTypedPtrArray::Add on Mon, 19 Jun 2006 10:46:03 GMT]]></title><description><![CDATA[<p>Versuchs mal so:</p>
<pre><code class="language-cpp">CArray &lt; CMyClass*, CMyClass* &gt; *m_pCMyClasses;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1080506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1080506</guid><dc:creator><![CDATA[connan]]></dc:creator><pubDate>Mon, 19 Jun 2006 10:46:03 GMT</pubDate></item><item><title><![CDATA[Reply to CTypedPtrArray::Add on Mon, 19 Jun 2006 10:18:27 GMT]]></title><description><![CDATA[<p>Wenn du Zeiger auf deine Objekte im TypedPtrArray speichern willst, dann muss der erste Templateparameter vom Typ CPtrArray sein.</p>
<pre><code class="language-cpp">CTypedPtrArray &lt; CPtrArray , CMyClass* &gt; *m_pCMyClasses;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1080514</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1080514</guid><dc:creator><![CDATA[Chris++ 0]]></dc:creator><pubDate>Mon, 19 Jun 2006 10:18:27 GMT</pubDate></item><item><title><![CDATA[Reply to CTypedPtrArray::Add on Mon, 19 Jun 2006 10:43:27 GMT]]></title><description><![CDATA[<p>diese Pointer machen mich noch wahnsinnig <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="🙂"
    /><br />
also eigentlich wollte ich wie oben beschrieben, beliebig viele Objekte vom typ MyClass im CTypedPtrArray speichern. Ob ich da nun Zeiger auf meine Objekte oder die Objekte selbst abspeichern muss, ist mir noch nicht ganz klar. Was wäre denn vorteilhafter? Später will ich auf diese Objekte über dieses Array zugreifen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1080517</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1080517</guid><dc:creator><![CDATA[toh]]></dc:creator><pubDate>Mon, 19 Jun 2006 10:43:27 GMT</pubDate></item></channel></rss>