<?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[vector mit zugriff auf struct komponenten]]></title><description><![CDATA[<p>Hallo Leute<br />
ich werde nicht schlauer mit vector und struct</p>
<p>ich möchte ein 2d vector erstellen und die komponenten von einem struct benutzen.</p>
<p>jedoch habe ich einige fehler, die ich nicht lösen kann.<br />
weiß jm was?</p>
<pre><code>struct Matrix {
	int zahl;
	bool istWeg = false;

};

Matrix vector &lt;vector&lt;unsigned int&gt;&gt; _2Dmatrix; // es wurde ein bezeichner erwartet
_2Dmatrix.resize(reihen,vector&lt;unsigned int&gt;(spalten,startwert);
_2Dmatrix.istWeg = true; // geht nicht

//wenn man mit array machen will dann klappt das
//Matrix arr[x][y];
//z.B arr[x][y].istWeg = true;
</code></pre>
<p>hat jm eine Erklärung<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>
]]></description><link>https://www.c-plusplus.net/forum/topic/340190/vector-mit-zugriff-auf-struct-komponenten</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 08:49:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/340190.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Oct 2016 18:39:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 18:40:40 GMT]]></title><description><![CDATA[<p>Hallo Leute<br />
ich werde nicht schlauer mit vector und struct</p>
<p>ich möchte ein 2d vector erstellen und die komponenten von einem struct benutzen.</p>
<p>jedoch habe ich einige fehler, die ich nicht lösen kann.<br />
weiß jm was?</p>
<pre><code>struct Matrix {
	int zahl;
	bool istWeg = false;

};

Matrix vector &lt;vector&lt;unsigned int&gt;&gt; _2Dmatrix; // es wurde ein bezeichner erwartet
_2Dmatrix.resize(reihen,vector&lt;unsigned int&gt;(spalten,startwert);
_2Dmatrix.istWeg = true; // geht nicht

//wenn man mit array machen will dann klappt das
//Matrix arr[x][y];
//z.B arr[x][y].istWeg = true;
</code></pre>
<p>hat jm eine Erklärung<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>
]]></description><link>https://www.c-plusplus.net/forum/post/2512743</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512743</guid><dc:creator><![CDATA[yeurandom92]]></dc:creator><pubDate>Mon, 24 Oct 2016 18:40:40 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 18:41:11 GMT]]></title><description><![CDATA[<p>yeurandom92 schrieb:</p>
<blockquote>
<p>hat jm eine Erklärung<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>
</blockquote>
<p>Nein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512744</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512744</guid><dc:creator><![CDATA[*blub*]]></dc:creator><pubDate>Mon, 24 Oct 2016 18:41:11 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 18:58:29 GMT]]></title><description><![CDATA[<p>Was macht das &quot;Matrix&quot; am Anfang von Zeile 7?</p>
<p>Deine Bezeichner sind übrigens schrecklich: struct Matrix stellt keine MAtrix dar. vector&lt;vector&lt;unsigned&gt;&gt; ist so manches, aber keine Matrix. Bezeichner mit Unterstrich am Anfang sind reserviert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512746</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 24 Oct 2016 18:58:29 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 18:58:06 GMT]]></title><description><![CDATA[<p>So kannst du im strukt nicht initialisieren, du verwendest vector falsch, Google hilft</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512747</guid><dc:creator><![CDATA[Gast3]]></dc:creator><pubDate>Mon, 24 Oct 2016 18:58:06 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 19:16:34 GMT]]></title><description><![CDATA[<pre><code>#include &lt;vector&gt;
#include &lt;iostream&gt;

using namespace std;

struct Matrix {
    int zahl;
    bool istWeg;

};

int main()
{
   vector&lt; vector&lt;Matrix&gt; &gt; _2Dmatrix;

   //Platz für 3 mal 3 Einträge beschaffen
   _2Dmatrix.resize(3);
   for(int i = 0; i &lt; _2Dmatrix.size(); ++i)
      _2Dmatrix[i].resize(3);

   //ab hier jetzt von _2Dmatrix[0][0] bis _2Dmatrix[2][2] bearbeiten
   bool b = true;
   for(int i = 0; i &lt; 3; ++i)
      for(int j = 0; j &lt; 3; ++j)
      {
         Matrix m = {i * j, b = !b};
         _2Dmatrix[i][j] = m;
      }

   cout &lt;&lt; _2Dmatrix[1][2].zahl &lt;&lt; ' ' &lt;&lt; _2Dmatrix[1][2].istWeg &lt;&lt; '\n';
   cout &lt;&lt; _2Dmatrix[1][2].zahl &lt;&lt; ' ' &lt;&lt; _2Dmatrix[2][0].istWeg &lt;&lt; '\n';
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2512750</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512750</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Mon, 24 Oct 2016 19:16:34 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 19:25:48 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Was macht das &quot;Matrix&quot; am Anfang von Zeile 7?</p>
<p>Deine Bezeichner sind übrigens schrecklich: struct Matrix stellt keine MAtrix dar. vector&lt;vector&lt;unsigned&gt;&gt; ist so manches, aber keine Matrix. Bezeichner mit Unterstrich am Anfang sind reserviert.</p>
</blockquote>
<p>zeile 7 ist Strukturname<br />
wenn man auf komponenten in struct zugreifen will muss man doch ein deklarieren</p>
<pre><code>Beispiele:

  struct person {         /* deklariert den Strukturtyp person */
    int   alter;
    float gewicht;
    char  name[25];
  } adam, eva;            /* deklariert Variable des Typs person */

  struct person paul;     /* deklariert weitere Variable des Typs person */
  person paula;           /* Deklaration nur in C++ zulaessig bzw.
                             in C nach vorherigem typedef */

  paul.alter = 13;        /* Zuweisung von Werten an die */
  paul.gewicht = 47.8;    /* einzelnen Komponenten */
</code></pre>
<p>strukturtyp ist Matrix(Zeile7)<br />
variable des typs Matrix ist _2Dmatrix<br />
_2Dmatrix ist wie paul bzw paula und dann will ich dadurch zugriff auf komponenten im struct haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512752</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512752</guid><dc:creator><![CDATA[yeurandom92]]></dc:creator><pubDate>Mon, 24 Oct 2016 19:25:48 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 19:36:45 GMT]]></title><description><![CDATA[<p>Ich habe das vermutlich nicht gefragt, weil ich tatsächlich eine Erklärung brauchte...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512754</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 24 Oct 2016 19:36:45 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 19:47:33 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Ich habe das vermutlich nicht gefragt, weil ich tatsächlich eine Erklärung brauchte...</p>
</blockquote>
<p>hab dich falsch verstanden.<br />
ich wollte nur damit sagen dass ich danach arbeite und leider hat das nicht gestimmt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512755</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512755</guid><dc:creator><![CDATA[yeurandom92]]></dc:creator><pubDate>Mon, 24 Oct 2016 19:47:33 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 19:51:07 GMT]]></title><description><![CDATA[<p>Belli schrieb:</p>
<blockquote>
<pre><code>#include &lt;vector&gt;
#include &lt;iostream&gt;

using namespace std;

struct Matrix {
    int zahl;
    bool istWeg;
    
};
 
int main()
{
   vector&lt; vector&lt;Matrix&gt; &gt; _2Dmatrix;
   
   //Platz für 3 mal 3 Einträge beschaffen
   _2Dmatrix.resize(3);
   for(int i = 0; i &lt; _2Dmatrix.size(); ++i)
      _2Dmatrix[i].resize(3);
   
   //ab hier jetzt von _2Dmatrix[0][0] bis _2Dmatrix[2][2] bearbeiten
   bool b = true;
   for(int i = 0; i &lt; 3; ++i)
      for(int j = 0; j &lt; 3; ++j)
      {
         Matrix m = {i * j, b = !b};
         _2Dmatrix[i][j] = m;
      }
      
   cout &lt;&lt; _2Dmatrix[1][2].zahl &lt;&lt; ' ' &lt;&lt; _2Dmatrix[1][2].istWeg &lt;&lt; '\n';
   cout &lt;&lt; _2Dmatrix[1][2].zahl &lt;&lt; ' ' &lt;&lt; _2Dmatrix[2][0].istWeg &lt;&lt; '\n';
}
</code></pre>
</blockquote>
<p>wieso muss ich vector&lt;vector&lt;Matrix&gt;&gt; xyz schreiben anstatt vector&lt;vector&lt;int&gt;&gt; xyz;</p>
<p>wieso kann ich hier kein Wert zuweisen ?</p>
<pre><code>//Platz für n mal n Einträge beschaffen 
	_2Dmatrix.resize(reihen);
	for (int i = 0; i &lt; _2Dmatrix.size(); ++i)
		_2Dmatrix[i].resize(SPALTEN);

	//ab hier jetzt von _2Dmatrix[0][0] bis _2Dmatrix[2][2] bearbeiten 
	for (unsigned int i = 0; i &lt; reihen; i++) {
		for (unsigned int x = 0; x &lt; SPALTEN; x++) {
			_2Dmatrix[i][x] = x; // hier kann ich nicht zuweisen wegen struct komponenten 
//mit array wäre arr[i][x] = i; somit kann ich ausgeben 0 1 2 3...9
		}
		cout &lt;&lt; endl;
	}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2512756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512756</guid><dc:creator><![CDATA[yeurandom92]]></dc:creator><pubDate>Mon, 24 Oct 2016 19:51:07 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 19:58:16 GMT]]></title><description><![CDATA[<p>yeurandom92 schrieb:</p>
<blockquote>
<p>wieso muss ich vector&lt;vector&lt;Matrix&gt;&gt; xyz schreiben anstatt vector&lt;vector&lt;int&gt;&gt; xyz;</p>
</blockquote>
<p>Was macht das int deiner Meinung nach?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512757</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 24 Oct 2016 19:58:16 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 20:12:55 GMT]]></title><description><![CDATA[<p>manni66 schrieb:</p>
<blockquote>
<p>yeurandom92 schrieb:</p>
<blockquote>
<p>wieso muss ich vector&lt;vector&lt;Matrix&gt;&gt; xyz schreiben anstatt vector&lt;vector&lt;int&gt;&gt; xyz;</p>
</blockquote>
<p>Was macht das int deiner Meinung nach?</p>
</blockquote>
<p>ein vector mit elementen typ integer</p>
<p>zitiert ausm skript<br />
vector&lt;double&gt; v ; // Noch l e e r e r Vektor f u e r double−Werte<br />
vector&lt;int&gt; w( 10 ) ; // Vektor mi t Pl a t z f u e r 10 i n t−Werte</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512758</guid><dc:creator><![CDATA[yeurandom92]]></dc:creator><pubDate>Mon, 24 Oct 2016 20:12:55 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 20:09:46 GMT]]></title><description><![CDATA[<p>Nein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512759</guid><dc:creator><![CDATA[*blub*]]></dc:creator><pubDate>Mon, 24 Oct 2016 20:09:46 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 20:35:27 GMT]]></title><description><![CDATA[<p>yeurandom92 schrieb:</p>
<blockquote>
<p>manni66 schrieb:</p>
<blockquote>
<p>yeurandom92 schrieb:</p>
<blockquote>
<p>wieso muss ich vector&lt;vector&lt;Matrix&gt;&gt; xyz schreiben anstatt vector&lt;vector&lt;int&gt;&gt; xyz;</p>
</blockquote>
<p>Was macht das int deiner Meinung nach?</p>
</blockquote>
<p>ein vector mit elementen typ integer</p>
<p>zitiert ausm skript<br />
vector&lt;double&gt; v ; // Noch l e e r e r Vektor f u e r double−Werte<br />
vector&lt;int&gt; w( 10 ) ; // Vektor mi t Pl a t z f u e r 10 i n t−Werte</p>
</blockquote>
<p>Und was willst du dort reinstecken?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512762</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512762</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 24 Oct 2016 20:35:27 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Mon, 24 Oct 2016 20:54:10 GMT]]></title><description><![CDATA[<p>yeurandom92 schrieb:</p>
<blockquote>
<p>wieso muss ich vector&lt;vector&lt;Matrix&gt;&gt; xyz schreiben anstatt vector&lt;vector&lt;int&gt;&gt; xyz;</p>
</blockquote>
<p>Weil Du in Deinem Eingangsposting so getan hast, als ob Du den Typ Matrix in Deinen Vektor stecken willst:</p>
<p>yeurandom92 schrieb:</p>
<blockquote>
<p>//wenn man mit array machen will dann klappt das<br />
//Matrix arr[x][y];</p>
</blockquote>
<p>Da kommt schließlich auch kein int vor. Da hast Du ein Array vom Typ Matrix, und in meinem Beispiel hast Du einen Vektor mit Vektoren vom Typ Matrix.</p>
<p>yeurandom92 schrieb:</p>
<blockquote>
<p>wieso kann ich hier kein Wert zuweisen ?</p>
<pre><code>for (unsigned int x = 0; x &lt; SPALTEN; x++) {
            _2Dmatrix[i][x] = x;
</code></pre>
</blockquote>
<p>Weil x vom Typ unsigned int ist, der Vektor aber Elemente vom Typ Matrix beheimatet.<br />
Das würde mit Deinem</p>
<pre><code>Matrix arr[x][y];
</code></pre>
<p>auch nicht funktionieren.<br />
Du könntest aber natürlich</p>
<pre><code>for (unsigned int x = 0; x &lt; SPALTEN; x++) {
            _2Dmatrix[i][x].zahl = x;
</code></pre>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox1357" checked="true" /><label for="checkbox1357">ein Wert Typ Matrix steckt, der die beiden Elemente zahl und istWeg hat, und zahl den Typ int hat</label></div></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512765</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512765</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Mon, 24 Oct 2016 20:54:10 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Tue, 25 Oct 2016 12:56:00 GMT]]></title><description><![CDATA[<p>Belli schrieb:</p>
<blockquote>
<p>yeurandom92 schrieb:</p>
<blockquote>
<p>wieso muss ich vector&lt;vector&lt;Matrix&gt;&gt; xyz schreiben anstatt vector&lt;vector&lt;int&gt;&gt; xyz;</p>
</blockquote>
<p>Weil Du in Deinem Eingangsposting so getan hast, als ob Du den Typ Matrix in Deinen Vektor stecken willst:</p>
<p>yeurandom92 schrieb:</p>
<blockquote>
<p>//wenn man mit array machen will dann klappt das<br />
//Matrix arr[x][y];</p>
</blockquote>
<p>Da kommt schließlich auch kein int vor. Da hast Du ein Array vom Typ Matrix, und in meinem Beispiel hast Du einen Vektor mit Vektoren vom Typ Matrix.</p>
<p>yeurandom92 schrieb:</p>
<blockquote>
<p>wieso kann ich hier kein Wert zuweisen ?</p>
<pre><code>for (unsigned int x = 0; x &lt; SPALTEN; x++) {
            _2Dmatrix[i][x] = x;
</code></pre>
</blockquote>
<p>Weil x vom Typ unsigned int ist, der Vektor aber Elemente vom Typ Matrix beheimatet.<br />
Das würde mit Deinem</p>
<pre><code>Matrix arr[x][y];
</code></pre>
<p>auch nicht funktionieren.<br />
Du könntest aber natürlich</p>
<pre><code>for (unsigned int x = 0; x &lt; SPALTEN; x++) {
            _2Dmatrix[i][x].zahl = x;
</code></pre>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox1358" checked="true" /><label for="checkbox1358">ein Wert Typ Matrix steckt, der die beiden Elemente zahl und istWeg hat, und zahl den Typ int hat</label></div></p>
</blockquote>
<p>danke dir für die ausführliche Erklärung<br />
ich habe daraus eine Lösung gebastelt<br />
ich benutze vector&lt;vector&lt;Matrix&gt;&gt;matrix und ich kann auf komponenten zugreifen.</p>
<p>würde es trotzdem reichen wenn ich schreibe</p>
<pre><code>struct Matrix{
int wert;
bool istWeg;
};
vector&lt;vector&lt;int&gt;&gt; matrix;
//matrix.istWeg

//oder

vector&lt;vector&lt;Matrix&gt;&gt;matrix;
//matrix.istweg
</code></pre>
<p>Ich habe noch nicht verstanden bzw ich weiß noch nicht was man in &lt;...&gt; eingeben soll um auf komponenten zuzugreifen. &lt;Matrix&gt; oder &lt;int&gt; und warum?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512819</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512819</guid><dc:creator><![CDATA[yeurandom92]]></dc:creator><pubDate>Tue, 25 Oct 2016 12:56:00 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Tue, 25 Oct 2016 13:08:22 GMT]]></title><description><![CDATA[<p>Ein Quell deiner der Verwirrung könnte hier die Namensgebung (auch wichtig!) sein.</p>
<p>Unter einer Matrix versteht man im allgemeinen ein zweidimensionales Gebilde mit einer definierten Anzahl Zeilen und Spalten. Das ist bei dir modelliert als <code>vector&lt;vector&lt; ... &gt;&gt;</code> .</p>
<p>Das, was du &quot;Matrix&quot; nennst (die Klasse), modelliert hingegen keine Matrix, sondern das Element in der Matrix. Die Klasse sollte daher besser <code>MatrixElement</code> statt <code>Matrix</code> heißen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512821</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512821</guid><dc:creator><![CDATA[wob]]></dc:creator><pubDate>Tue, 25 Oct 2016 13:08:22 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Tue, 25 Oct 2016 14:20:56 GMT]]></title><description><![CDATA[<p>wob schrieb:</p>
<blockquote>
<p>Ein Quell deiner der Verwirrung könnte hier die Namensgebung (auch wichtig!) sein.</p>
<p>Unter einer Matrix versteht man im allgemeinen ein zweidimensionales Gebilde mit einer definierten Anzahl Zeilen und Spalten. Das ist bei dir modelliert als <code>vector&lt;vector&lt; ... &gt;&gt;</code> .</p>
<p>Das, was du &quot;Matrix&quot; nennst (die Klasse), modelliert hingegen keine Matrix, sondern das Element in der Matrix. Die Klasse sollte daher besser <code>MatrixElement</code> statt <code>Matrix</code> heißen.</p>
</blockquote>
<p>Bedeutet: wenn ich vector xyz benutze, ganz egal ob 2d vector&lt;vector&lt;&gt;&gt;xyz oder 1d vektor.<br />
wenn ich zugriff auf komponenten in struct mit Vektor realisieren will, muss ich in<br />
&lt;...&gt; &quot;structname&quot; eingeben. In diesem Fall Matrixelement ?</p>
<p>wenn ich int, float oder was anderes eingebe, dann ist es nur ein vektor mit dementspechend int , float usw. elementen.</p>
<p>Danke fuer die Hilfe an euch.<br />
Wieder was dazu gelernt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512836</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512836</guid><dc:creator><![CDATA[yeurandom92]]></dc:creator><pubDate>Tue, 25 Oct 2016 14:20:56 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Tue, 25 Oct 2016 14:32:14 GMT]]></title><description><![CDATA[<p>yeurandom92 schrieb:</p>
<blockquote>
<p>würde es trotzdem reichen wenn ich schreibe</p>
<pre><code>struct Matrix{
int wert;
bool istWeg;
};
vector&lt;vector&lt;int&gt;&gt; matrix;
//matrix.istWeg

//oder

vector&lt;vector&lt;Matrix&gt;&gt;matrix;
//matrix.istweg
</code></pre>
<p>Ich habe noch nicht verstanden bzw ich weiß noch nicht was man in &lt;...&gt; eingeben soll um auf komponenten zuzugreifen. &lt;Matrix&gt; oder &lt;int&gt; und warum?</p>
</blockquote>
<p>Im ersten Fall</p>
<pre><code>vector&lt;vector&lt;int&gt;&gt; matrix;
</code></pre>
<p>ist matrix doch nur der Name des Vektors, ähnlich wie in</p>
<pre><code>int matrix[10][10];
</code></pre>
<p>die Elemente des Vektors sind aber int - Werte, auf die Du mit</p>
<pre><code>matrix[2][2]
</code></pre>
<p>zugreifen kannst.<br />
Du willst aber</p>
<pre><code>Matrix array[10][10];
</code></pre>
<p>in einem Vektor haben, und da ist die Entsprechung</p>
<pre><code>vector&lt; vector&lt;Matrix&gt; &gt; vektor;
</code></pre>
<p>mal davon abgesehen, dass Du dem Vektor jetzt erst mal Elemente hinzufügen musst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512838</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512838</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Tue, 25 Oct 2016 14:32:14 GMT</pubDate></item><item><title><![CDATA[Reply to vector mit zugriff auf struct komponenten on Tue, 25 Oct 2016 14:47:28 GMT]]></title><description><![CDATA[<p>Und dann kannst du per</p>
<pre><code class="language-cpp">typedef vector&lt;vector&lt;MatrixElement&gt;&gt; Matrix;
</code></pre>
<p>einen Aliasnamen deklarieren, so daß du dann</p>
<pre><code class="language-cpp">Matrix matrix;
</code></pre>
<p>schreiben kannst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2512841</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2512841</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Tue, 25 Oct 2016 14:47:28 GMT</pubDate></item></channel></rss>