<?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[Probleme mit statischem Feld]]></title><description><![CDATA[<p>Servus,</p>
<p>ich möchte eine Klasse schreiben, die ähnlich einem Singleton ist. Nur sollen mehrere Instanzen der Klasse erlaubt sein und diese in einem Array gespeichert werden. Aber irgendwo gibt es ein Problem beim initialisieren. Hier mal der Code und die Fehlermeldungen:</p>
<p>class RS232{<br />
static RS232* openPorts[DIM];<br />
static HANDLE rs_handles[DIM];<br />
char buffer[255];<br />
DWORD eventMask;<br />
DCB dcb;<br />
....</p>
<p>#include &quot;RS232.h&quot;</p>
<p>RS232* RS232::openPorts[0] = NULL;<br />
RS232* RS232::openPorts[1] = NULL;<br />
RS232* RS232::openPorts[2] = NULL;<br />
RS232* RS232::openPorts[3] = NULL;</p>
<p>HANDLE RS232::rs_handles[0] = 0;<br />
HANDLE RS232::rs_handles[1] = 0;<br />
HANDLE RS232::rs_handles[2] = 0;<br />
HANDLE RS232::rs_handles[3] = 0;</p>
<p>....</p>
<p>und nun die Fehlermeldungen:<br />
D:\MyProjects\RS232\RS232.CPP(4) : error C2466: Reservierung eines Feldes der konstanten Groesse 0 nicht moeglich<br />
D:\MyProjects\RS232\RS232.CPP(4) : error C2440: 'initializing' : 'const int' kann nicht in 'class RS232 *[4]' konvertiert werden<br />
Es gibt keine Konvertierungen von Feldtypen, obwohl es Konvertierungen von Verweisen oder Zeigern in Felder gibt<br />
D:\MyProjects\RS232\RS232.CPP(5) : error C2369: 'private: static class RS232 * * RS232::openPorts' : Neudefinition; unterschiedliche Feldindizes<br />
d:\myprojects\rs232\rs232.h(10) : Siehe Deklaration von 'private: static class RS232 * * RS232::openPorts'<br />
D:\MyProjects\RS232\RS232.CPP(6) : error C2369: 'private: static class RS232 * * RS232::openPorts' : Neudefinition; unterschiedliche Feldindizes<br />
d:\myprojects\rs232\rs232.h(10) : Siehe Deklaration von 'private: static class RS232 * * RS232::openPorts'</p>
<p>Kann mir jemand weiterhelfen??</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/122459/probleme-mit-statischem-feld</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 03:38:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/122459.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 06 Oct 2005 06:25:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit statischem Feld on Thu, 06 Oct 2005 06:25:58 GMT]]></title><description><![CDATA[<p>Servus,</p>
<p>ich möchte eine Klasse schreiben, die ähnlich einem Singleton ist. Nur sollen mehrere Instanzen der Klasse erlaubt sein und diese in einem Array gespeichert werden. Aber irgendwo gibt es ein Problem beim initialisieren. Hier mal der Code und die Fehlermeldungen:</p>
<p>class RS232{<br />
static RS232* openPorts[DIM];<br />
static HANDLE rs_handles[DIM];<br />
char buffer[255];<br />
DWORD eventMask;<br />
DCB dcb;<br />
....</p>
<p>#include &quot;RS232.h&quot;</p>
<p>RS232* RS232::openPorts[0] = NULL;<br />
RS232* RS232::openPorts[1] = NULL;<br />
RS232* RS232::openPorts[2] = NULL;<br />
RS232* RS232::openPorts[3] = NULL;</p>
<p>HANDLE RS232::rs_handles[0] = 0;<br />
HANDLE RS232::rs_handles[1] = 0;<br />
HANDLE RS232::rs_handles[2] = 0;<br />
HANDLE RS232::rs_handles[3] = 0;</p>
<p>....</p>
<p>und nun die Fehlermeldungen:<br />
D:\MyProjects\RS232\RS232.CPP(4) : error C2466: Reservierung eines Feldes der konstanten Groesse 0 nicht moeglich<br />
D:\MyProjects\RS232\RS232.CPP(4) : error C2440: 'initializing' : 'const int' kann nicht in 'class RS232 *[4]' konvertiert werden<br />
Es gibt keine Konvertierungen von Feldtypen, obwohl es Konvertierungen von Verweisen oder Zeigern in Felder gibt<br />
D:\MyProjects\RS232\RS232.CPP(5) : error C2369: 'private: static class RS232 * * RS232::openPorts' : Neudefinition; unterschiedliche Feldindizes<br />
d:\myprojects\rs232\rs232.h(10) : Siehe Deklaration von 'private: static class RS232 * * RS232::openPorts'<br />
D:\MyProjects\RS232\RS232.CPP(6) : error C2369: 'private: static class RS232 * * RS232::openPorts' : Neudefinition; unterschiedliche Feldindizes<br />
d:\myprojects\rs232\rs232.h(10) : Siehe Deklaration von 'private: static class RS232 * * RS232::openPorts'</p>
<p>Kann mir jemand weiterhelfen??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/886124</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/886124</guid><dc:creator><![CDATA[c++ newbie]]></dc:creator><pubDate>Thu, 06 Oct 2005 06:25:58 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit statischem Feld on Thu, 06 Oct 2005 06:33:34 GMT]]></title><description><![CDATA[<p>So geht das auch nicht.</p>
<p>Es gibt in C++ in der Form keine Einzelfeldinitialiserung fuer Arrays.</p>
<p>Die einzige Moeglichkeit ist:</p>
<pre><code class="language-cpp">RS232* RS232::openPorts[DIM] = { NULL, NULL, NULL, NULL };

HANDLE RS232::rs_handles[DIM] = { 0, 0, 0, 0 };
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/886129</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/886129</guid><dc:creator><![CDATA[Power Off]]></dc:creator><pubDate>Thu, 06 Oct 2005 06:33:34 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit statischem Feld on Thu, 06 Oct 2005 06:52:01 GMT]]></title><description><![CDATA[<p>So gehts. Danke für die schnelle Hilfe!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/886138</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/886138</guid><dc:creator><![CDATA[c++ newbie]]></dc:creator><pubDate>Thu, 06 Oct 2005 06:52:01 GMT</pubDate></item></channel></rss>