<?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[array im private Berreich erst später deklarieren]]></title><description><![CDATA[<p>Hi,<br />
Ich bin gerade dabei eine kleine Netzwerklib für meine Programme auf Socket Basis zu bauen.<br />
Bei dem Server Bereich habe ich jedoch ein Problem und zwar möchte ich im private Bereich ein Socket Array erstellen damit alle Funktionen der Klasse darauf zugreifen können. Aber ich bekomme ja erst die slotanzahl beim erstellen des Objektes mitgeteilt, wie kann ich nun das array im private berreich darauf anpassen?<br />
Hier nochmal an einem Beispiel deutlich gemacht:</p>
<pre><code class="language-cpp">class server {
private:
#ifdef WIN32
SOCKET sock[slots];
#else
int sock[slots];
#endif
public:
server(int slots); //Hier bekomme ich nun die Slotanzahl die ich im private Berreich einsetzen muss!
};
</code></pre>
<p>MFG ReduX</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/200562/array-im-private-berreich-erst-später-deklarieren</link><generator>RSS for Node</generator><lastBuildDate>Mon, 29 Jun 2026 05:59:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/200562.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 16 Dec 2007 18:55:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Sun, 16 Dec 2007 18:55:21 GMT]]></title><description><![CDATA[<p>Hi,<br />
Ich bin gerade dabei eine kleine Netzwerklib für meine Programme auf Socket Basis zu bauen.<br />
Bei dem Server Bereich habe ich jedoch ein Problem und zwar möchte ich im private Bereich ein Socket Array erstellen damit alle Funktionen der Klasse darauf zugreifen können. Aber ich bekomme ja erst die slotanzahl beim erstellen des Objektes mitgeteilt, wie kann ich nun das array im private berreich darauf anpassen?<br />
Hier nochmal an einem Beispiel deutlich gemacht:</p>
<pre><code class="language-cpp">class server {
private:
#ifdef WIN32
SOCKET sock[slots];
#else
int sock[slots];
#endif
public:
server(int slots); //Hier bekomme ich nun die Slotanzahl die ich im private Berreich einsetzen muss!
};
</code></pre>
<p>MFG ReduX</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1421550</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1421550</guid><dc:creator><![CDATA[ReduX]]></dc:creator><pubDate>Sun, 16 Dec 2007 18:55:21 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Sun, 16 Dec 2007 18:56:48 GMT]]></title><description><![CDATA[<p>std::vector</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1421552</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1421552</guid><dc:creator><![CDATA[stichwort]]></dc:creator><pubDate>Sun, 16 Dec 2007 18:56:48 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Sun, 16 Dec 2007 19:18:21 GMT]]></title><description><![CDATA[<p>new oder malloc tun's auch.<br />
<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="🙂"
    /></p>
<p>übrigens, besser</p>
<pre><code>#ifndef WIN32
#define SOCKET int
#endif
</code></pre>
<p>als</p>
<pre><code>#ifdef WIN32
SOCKET sock[slots];
#else
int sock[slots];
#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1421573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1421573</guid><dc:creator><![CDATA[#define-freak]]></dc:creator><pubDate>Sun, 16 Dec 2007 19:18:21 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Sun, 16 Dec 2007 22:39:37 GMT]]></title><description><![CDATA[<p>Ja, oder SOCKET kapseln:</p>
<pre><code class="language-cpp">class socket : private boost::noncopyable
{
#ifdef _WIN32
   // ...
#else
   // ...
#endif
};
</code></pre>
<p>Oder gleich Boost.ASIO o.ä. verwenden.</p>
<p>p.S.:</p>
<blockquote>
<pre><code>#ifndef WIN32 
#define SOCKET int 
#endif
</code></pre>
</blockquote>
<p>Bitte typedef, nicht #define.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1421711</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1421711</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 16 Dec 2007 22:39:37 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Mon, 17 Dec 2007 17:23:21 GMT]]></title><description><![CDATA[<p>Hi,<br />
Danke für eure Antworten.<br />
Werde wohl new verwenden <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="🙂"
    /></p>
<pre><code>#ifndef WIN32
#define SOCKET int
#endif
</code></pre>
<p>Sollte das nicht:</p>
<pre><code>#ifndef WIN32
typedef int SOCKET;
#endif
</code></pre>
<p>heißen???</p>
<p>MFG ReduX</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422165</guid><dc:creator><![CDATA[ReduX]]></dc:creator><pubDate>Mon, 17 Dec 2007 17:23:21 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Mon, 17 Dec 2007 18:29:31 GMT]]></title><description><![CDATA[<p>ReduX schrieb:</p>
<blockquote>
<p>Werde wohl new verwenden <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="🙂"
    /></p>
</blockquote>
<p>warum? was spricht denn gegen</p>
<p>stichwort schrieb:</p>
<blockquote>
<p>std::vector</p>
</blockquote>
<p>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422206</guid><dc:creator><![CDATA[der mob]]></dc:creator><pubDate>Mon, 17 Dec 2007 18:29:31 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Mon, 17 Dec 2007 19:04:38 GMT]]></title><description><![CDATA[<p>Eigentlich nichts...<br />
Bin jedoch mit new mehr vertraut!</p>
<p>MFG ReduX :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422227</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422227</guid><dc:creator><![CDATA[ReduX]]></dc:creator><pubDate>Mon, 17 Dec 2007 19:04:38 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Tue, 18 Dec 2007 09:49:29 GMT]]></title><description><![CDATA[<p>trau dich an std::vector, wirst sehen das es ganz easy ist und viel komfortabler als new :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422437</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422437</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Tue, 18 Dec 2007 09:49:29 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Tue, 18 Dec 2007 11:49:22 GMT]]></title><description><![CDATA[<p>Vor allem ist es viel mehr C++ als new <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422501</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422501</guid><dc:creator><![CDATA[mad_martin]]></dc:creator><pubDate>Tue, 18 Dec 2007 11:49:22 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Tue, 18 Dec 2007 12:13:52 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">vector&lt;int&gt;* array = new vector&lt;int&gt;();
</code></pre>
<p>Geht doch auch mit new <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";D"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422522</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422522</guid><dc:creator><![CDATA[Zeus]]></dc:creator><pubDate>Tue, 18 Dec 2007 12:13:52 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Tue, 18 Dec 2007 16:50:16 GMT]]></title><description><![CDATA[<p>Hi,<br />
Warum funktioniert bei vector folgendes nicht:</p>
<pre><code>std::vector&lt;SOCKET&gt; clients;
</code></pre>
<p>Dort kommt die Meldung:<br />
ISO C++ verbietet vector ohnen typ.<br />
Aber der Typ SOCKET hab ich ja mit typedef deklariert!</p>
<p>MFG ReduX :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422751</guid><dc:creator><![CDATA[ReduX]]></dc:creator><pubDate>Tue, 18 Dec 2007 16:50:16 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Tue, 18 Dec 2007 17:57:54 GMT]]></title><description><![CDATA[<p>Zeig mal mehr von deinem Code</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422781</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422781</guid><dc:creator><![CDATA[Zeus]]></dc:creator><pubDate>Tue, 18 Dec 2007 17:57:54 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Tue, 18 Dec 2007 19:55:05 GMT]]></title><description><![CDATA[<p>Hi,<br />
Ja also am Anfang halt:</p>
<pre><code class="language-cpp">#ifndef WIN32
typedef int SOCKET;
#endif
</code></pre>
<p>Und in der Klasse im private Berreich dann:</p>
<pre><code class="language-cpp">std::vector&lt;SOCKET&gt; clients;
</code></pre>
<p>MFG ReduX :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422825</guid><dc:creator><![CDATA[ReduX]]></dc:creator><pubDate>Tue, 18 Dec 2007 19:55:05 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Tue, 18 Dec 2007 22:04:13 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#ifdef WIN32
    typedef SOCKET socket_t;
#else
    typedef int socket_t;
#endif

typedef std::vector&lt;socket_t&gt; socket_vector;

socket_vector clients;
</code></pre>
<p>was sagt der compiler dazu?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1422872</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1422872</guid><dc:creator><![CDATA[die mobs]]></dc:creator><pubDate>Tue, 18 Dec 2007 22:04:13 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Wed, 19 Dec 2007 14:55:12 GMT]]></title><description><![CDATA[<p>Hi,<br />
Dann bekomme ich vom Compiler:</p>
<pre><code>expected initializer before »&lt;« token
</code></pre>
<p>Verstehe ich aber nicht!</p>
<p>MFG ReduX :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1423286</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1423286</guid><dc:creator><![CDATA[ReduX]]></dc:creator><pubDate>Wed, 19 Dec 2007 14:55:12 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Wed, 19 Dec 2007 15:01:06 GMT]]></title><description><![CDATA[<p>Hast du eventuell vergessen, den Header &lt;vector&gt; einzubinden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1423290</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1423290</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 19 Dec 2007 15:01:06 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Wed, 19 Dec 2007 15:20:34 GMT]]></title><description><![CDATA[<p>Hi,<br />
Hatte ihn nicht includiert macht aber keinen unterschied wenn ich ihn reinmache!</p>
<p>MFG ReduX :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1423295</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1423295</guid><dc:creator><![CDATA[ReduX]]></dc:creator><pubDate>Wed, 19 Dec 2007 15:20:34 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Wed, 19 Dec 2007 15:38:18 GMT]]></title><description><![CDATA[<p>dann zeig doch mal mehr code.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1423302</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1423302</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Wed, 19 Dec 2007 15:38:18 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Thu, 20 Dec 2007 11:25:15 GMT]]></title><description><![CDATA[<p>Hi,<br />
Hier mal das wesentliche:<br />
MEINNAMESPACE.h:</p>
<pre><code class="language-cpp">#ifdef WIN32
typedef SOCKET socket_t;
#else
typedef int socket_t;
#endif
typedef std::vector&lt;socket_t&gt; socket_vector;
#include &lt;vector&gt;
#include &lt;string&gt;
namspace MEINNAMESPACE {
class MEINECLASS {
private:
socket_vector clients;
public:
//....
};
}
</code></pre>
<p>MFG ReduX :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1423322</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1423322</guid><dc:creator><![CDATA[ReduX]]></dc:creator><pubDate>Thu, 20 Dec 2007 11:25:15 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Wed, 19 Dec 2007 16:26:26 GMT]]></title><description><![CDATA[<p>du solltest &lt;vector&gt; vielleicht früher inkludieren. am besten bevor du vector&lt;&gt; zum ersten mal verwendest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1423323</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1423323</guid><dc:creator><![CDATA[der mops]]></dc:creator><pubDate>Wed, 19 Dec 2007 16:26:26 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Wed, 19 Dec 2007 16:29:09 GMT]]></title><description><![CDATA[<p>Hi,<br />
Danke jetzt Funktionierts.<br />
War ein dummer leichzinsfehler von mir <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /><br />
Irgendwie wird im Post über mir der Code nicht in so ein kasten gepackt hab aber bbc verwendet.</p>
<p>MFG ReduX :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1423327</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1423327</guid><dc:creator><![CDATA[ReduX]]></dc:creator><pubDate>Wed, 19 Dec 2007 16:29:09 GMT</pubDate></item><item><title><![CDATA[Reply to array im private Berreich erst später deklarieren on Wed, 19 Dec 2007 16:34:21 GMT]]></title><description><![CDATA[<p>das mit der darstellung liegt daran, dass mitten in deinem code ein [/code] drinsteht, das da nix zu suchen hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1423329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1423329</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Wed, 19 Dec 2007 16:34:21 GMT</pubDate></item></channel></rss>