<?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[Vektor schnell und praktikabel mit füllen...]]></title><description><![CDATA[<p>Guten Abend,</p>
<p>Ich benötige ein zweidimensionalen Vektor,<br />
den ich einfach mit Werten füllen kann.</p>
<p>Werte: (0,1) , (3,8) , (4,4) , (4,3) , (2,7)</p>
<p>Ich möchte nicht ständig MeinVektor[7][0] = 5; MeinVektor[7][1] = 9; ... im Quelltext stehen haben. <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>
]]></description><link>https://www.c-plusplus.net/forum/topic/97932/vektor-schnell-und-praktikabel-mit-füllen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 06 Sep 2026 01:28:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/97932.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Jan 2005 23:29:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Fri, 14 Jan 2005 23:29:22 GMT]]></title><description><![CDATA[<p>Guten Abend,</p>
<p>Ich benötige ein zweidimensionalen Vektor,<br />
den ich einfach mit Werten füllen kann.</p>
<p>Werte: (0,1) , (3,8) , (4,4) , (4,3) , (2,7)</p>
<p>Ich möchte nicht ständig MeinVektor[7][0] = 5; MeinVektor[7][1] = 9; ... im Quelltext stehen haben. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/696777</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/696777</guid><dc:creator><![CDATA[bertold]]></dc:creator><pubDate>Fri, 14 Jan 2005 23:29:22 GMT</pubDate></item><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Sat, 15 Jan 2005 01:30:18 GMT]]></title><description><![CDATA[<p>naja dann machst du dir ne klasse mit namen Vector2d, machst eine funktion namens setCoord(int, int, int, int), überlädst nen paar operatoren und fertig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/696794</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/696794</guid><dc:creator><![CDATA[borg]]></dc:creator><pubDate>Sat, 15 Jan 2005 01:30:18 GMT</pubDate></item><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Sat, 15 Jan 2005 01:16:00 GMT]]></title><description><![CDATA[<p>hi!</p>
<p>da wäre ja schon eine map besser zu verwenden?!?</p>
<p>cu</p>
]]></description><link>https://www.c-plusplus.net/forum/post/696833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/696833</guid><dc:creator><![CDATA[cpluusplus]]></dc:creator><pubDate>Sat, 15 Jan 2005 01:16:00 GMT</pubDate></item><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Sat, 15 Jan 2005 07:55:50 GMT]]></title><description><![CDATA[<p>Bertold. Wie stellst du dir das denn vor? Du musst schon sagen in welcher Form du die initialisierenden Werte vorliegen hast, damit man dir eine elegante Lösung vorschlagen kann. Im Moment fällt mir nur <a href="http://boost.org/libs/assign/doc/index.html" rel="nofollow">boost::assign</a> ein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/696884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/696884</guid><dc:creator><![CDATA[Walli]]></dc:creator><pubDate>Sat, 15 Jan 2005 07:55:50 GMT</pubDate></item><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Sat, 15 Jan 2005 08:36:07 GMT]]></title><description><![CDATA[<p>Wenn es dir nur darum geht die Daten nicht im Code stehen zu haben, hielte ich es für elegant diese aus einer Datei einzulesen, ausserdem kannst du dann später ohne das Prog neu Kompilieren zu müssen beliebig Vektoren hinzufügen, ändern und entfernen. Es fragt sich sich nur, ob sich der Aufwand für dich lohnt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/696893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/696893</guid><dc:creator><![CDATA[Lord Apophis]]></dc:creator><pubDate>Sat, 15 Jan 2005 08:36:07 GMT</pubDate></item><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Sat, 15 Jan 2005 09:00:34 GMT]]></title><description><![CDATA[<p>bertold schrieb:</p>
<blockquote>
<p>...Ich benötige ein zweidimensionalen Vektor...MeinVektor[7][0] = 5; MeinVektor[7][1] = 9;...</p>
</blockquote>
<p>sag mal, meinst du 'vector' oder 'array' ? sind ja doch ne handvoll unterschiede</p>
]]></description><link>https://www.c-plusplus.net/forum/post/696898</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/696898</guid><dc:creator><![CDATA[enno-tyrant]]></dc:creator><pubDate>Sat, 15 Jan 2005 09:00:34 GMT</pubDate></item><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Sat, 15 Jan 2005 09:37:13 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">class Vektor2D
{
public:
    Vektor2D(int x, int y) : m_x(x), m_y(y) {}
    int &amp;operator[] (unsigned index)
    {
        if (index == 0) return &amp;m_x;
        else if (index == 1) return &amp;m_y;
        throw std::exception(&quot;invalid index&quot;);
    ]
private:
   int m_x, m_y;
};

...

Vektor2D myVek(2, 3);
myVek[0] = 3;
</code></pre>
<p>sowas vielleicht?=</p>
]]></description><link>https://www.c-plusplus.net/forum/post/696907</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/696907</guid><dc:creator><![CDATA[Korbinian]]></dc:creator><pubDate>Sat, 15 Jan 2005 09:37:13 GMT</pubDate></item><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Sat, 15 Jan 2005 12:03:24 GMT]]></title><description><![CDATA[<p>Korbinian schrieb:</p>
<blockquote>
<pre><code class="language-cpp">class Vektor2D
{
public:
    Vektor2D(int x, int y) : m_x(x), m_y(y) {}
    int &amp;operator[] (unsigned index)
    {
        if (index == 0) return &amp;m_x;
        else if (index == 1) return &amp;m_y;
        throw std::exception(&quot;invalid index&quot;);
    ]
private:
   int m_x, m_y;
};

...

Vektor2D myVek(2, 3);
myVek[0] = 3;
</code></pre>
<p>sowas vielleicht?=</p>
</blockquote>
<p>Mal abgesehen, dass es IMO keinen Sinn macht bei nem 2D Vektor den operator[] zu überladen, gibst du die Adresse zurück. Du musst aber den Wert zurückgeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697021</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697021</guid><dc:creator><![CDATA[interpreter]]></dc:creator><pubDate>Sat, 15 Jan 2005 12:03:24 GMT</pubDate></item><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Sat, 15 Jan 2005 18:04:30 GMT]]></title><description><![CDATA[<p>jo kann sein. hab das shcon länger nicht mehr gemacht <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>
]]></description><link>https://www.c-plusplus.net/forum/post/697349</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697349</guid><dc:creator><![CDATA[Korbinian]]></dc:creator><pubDate>Sat, 15 Jan 2005 18:04:30 GMT</pubDate></item><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Sat, 15 Jan 2005 18:24:02 GMT]]></title><description><![CDATA[<p>Korbinian schrieb:</p>
<blockquote>
<p>jo kann sein. hab das shcon länger nicht mehr gemacht <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>Schlechte Antwort. Du hättest besser sagen sollen, dass du den absichtlich eingebaut hast um zum denken anzuregen ;D.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697372</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697372</guid><dc:creator><![CDATA[Walli]]></dc:creator><pubDate>Sat, 15 Jan 2005 18:24:02 GMT</pubDate></item><item><title><![CDATA[Reply to Vektor schnell und praktikabel mit füllen... on Wed, 21 Jun 2006 20:38:58 GMT]]></title><description><![CDATA[<p>wie wärs mit</p>
<pre><code>std::vector&lt;std::pair&gt; lala;
lala.push_back(std::pair(1,2));
</code></pre>
<p>oder so ähnlich</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1082506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1082506</guid><dc:creator><![CDATA[Gast25250]]></dc:creator><pubDate>Wed, 21 Jun 2006 20:38:58 GMT</pubDate></item></channel></rss>