<?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[multiset&amp;lt;struct&amp;gt; - Zugriff auf Elemente?]]></title><description><![CDATA[<p>Hallo allerseits,</p>
<p>ich habe wie die Überschrift schon sagt folgendes in einem H-File erstellt:</p>
<pre><code class="language-cpp">struct dataStructure
	{
		int trainId;
		int stationId;
		int arrivalHour;
		int arrivalMinute;
		int descentHour;
		int descentMinute;
		int countDropout;
		int countNewcomer;
	};

	/*
	 * Returns true, if the a entry is smaller than b.
	 */
	struct comp
	{
		bool operator() (const dataStructure a, const dataStructure b) const
		{
			return a.trainId &lt; b.trainId
				   &amp;&amp;
				   a.descentHour * 60 + a.descentMinute &lt;
				   b.descentHour * 60 + b.descentMinute;
		}
	};

	multiset&lt;dataStructure, comp&gt; records;
</code></pre>
<p>Die Elemente will ich jetzt Ausgeben bzw. auf sie zugreifen, in einem cpp File, die Befüllung mit Daten funktioniert - zumindest Comiliert er (ohne die Ausgabe) einwandfrei.</p>
<p>Nun habe ich keine Ahnung was ich noch machen soll, ich bin mir sicher das es am Iterator liegt... hier meine Ausgabe-Versuche:</p>
<pre><code class="language-cpp">for(multiset&lt;dataStructure&gt;::iterator i = records.begin(); i != records.end(); i++)
			cout &lt;&lt; *i.trainId &lt;&lt; &quot; &quot; &lt;&lt; *i.stationId &lt;&lt; &quot; &quot; &lt;&lt; *i.arrivalHour &lt;&lt; &quot; &quot; &lt;&lt; 
                        *i.arrivalMinute &lt;&lt; &quot; &quot; &lt;&lt; *i.descentHour &lt;&lt; &quot; &quot; &lt;&lt; *i.descentMinute &lt;&lt; &quot; &quot; &lt;&lt; 
                        *i.countDropout &lt;&lt; &quot; &quot; &lt;&lt; *i.countNewcomer &lt;&lt; endl;
</code></pre>
<pre><code class="language-cpp">for(unsigned int i = 0; i &lt; records.size(); i++)
			cout &lt;&lt; records[i].trainId &lt;&lt; &quot; &quot; &lt;&lt; records[i].stationId &lt;&lt; &quot; &quot; &lt;&lt; records[i].arrivalHour &lt;&lt; &quot; &quot; &lt;&lt; 
                        records[i].arrivalMinute &lt;&lt; &quot; &quot; &lt;&lt; records[i].descentHour &lt;&lt; &quot; &quot; &lt;&lt; records[i].descentMinute &lt;&lt; &quot; &quot; &lt;&lt; 
                        records[i].countDropout &lt;&lt; &quot; &quot; &lt;&lt; records[i].countNewcomer &lt;&lt; endl;
</code></pre>
<p>Habe schon die Suchfunktion, Google und einige Leute gefragt - Lösungen gab es keine :(, so langsam bin ich am verzweifeln. Vllt liegts auch daran, das ich in C++ erst 1 1/2 Wochen schreibe und noch ein Neuling bin.</p>
<p>Lg<br />
Copy</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/287347/multiset-lt-struct-gt-zugriff-auf-elemente</link><generator>RSS for Node</generator><lastBuildDate>Thu, 20 Aug 2026 11:23:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/287347.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 26 May 2011 18:42:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to multiset&amp;lt;struct&amp;gt; - Zugriff auf Elemente? on Thu, 26 May 2011 18:42:09 GMT]]></title><description><![CDATA[<p>Hallo allerseits,</p>
<p>ich habe wie die Überschrift schon sagt folgendes in einem H-File erstellt:</p>
<pre><code class="language-cpp">struct dataStructure
	{
		int trainId;
		int stationId;
		int arrivalHour;
		int arrivalMinute;
		int descentHour;
		int descentMinute;
		int countDropout;
		int countNewcomer;
	};

	/*
	 * Returns true, if the a entry is smaller than b.
	 */
	struct comp
	{
		bool operator() (const dataStructure a, const dataStructure b) const
		{
			return a.trainId &lt; b.trainId
				   &amp;&amp;
				   a.descentHour * 60 + a.descentMinute &lt;
				   b.descentHour * 60 + b.descentMinute;
		}
	};

	multiset&lt;dataStructure, comp&gt; records;
</code></pre>
<p>Die Elemente will ich jetzt Ausgeben bzw. auf sie zugreifen, in einem cpp File, die Befüllung mit Daten funktioniert - zumindest Comiliert er (ohne die Ausgabe) einwandfrei.</p>
<p>Nun habe ich keine Ahnung was ich noch machen soll, ich bin mir sicher das es am Iterator liegt... hier meine Ausgabe-Versuche:</p>
<pre><code class="language-cpp">for(multiset&lt;dataStructure&gt;::iterator i = records.begin(); i != records.end(); i++)
			cout &lt;&lt; *i.trainId &lt;&lt; &quot; &quot; &lt;&lt; *i.stationId &lt;&lt; &quot; &quot; &lt;&lt; *i.arrivalHour &lt;&lt; &quot; &quot; &lt;&lt; 
                        *i.arrivalMinute &lt;&lt; &quot; &quot; &lt;&lt; *i.descentHour &lt;&lt; &quot; &quot; &lt;&lt; *i.descentMinute &lt;&lt; &quot; &quot; &lt;&lt; 
                        *i.countDropout &lt;&lt; &quot; &quot; &lt;&lt; *i.countNewcomer &lt;&lt; endl;
</code></pre>
<pre><code class="language-cpp">for(unsigned int i = 0; i &lt; records.size(); i++)
			cout &lt;&lt; records[i].trainId &lt;&lt; &quot; &quot; &lt;&lt; records[i].stationId &lt;&lt; &quot; &quot; &lt;&lt; records[i].arrivalHour &lt;&lt; &quot; &quot; &lt;&lt; 
                        records[i].arrivalMinute &lt;&lt; &quot; &quot; &lt;&lt; records[i].descentHour &lt;&lt; &quot; &quot; &lt;&lt; records[i].descentMinute &lt;&lt; &quot; &quot; &lt;&lt; 
                        records[i].countDropout &lt;&lt; &quot; &quot; &lt;&lt; records[i].countNewcomer &lt;&lt; endl;
</code></pre>
<p>Habe schon die Suchfunktion, Google und einige Leute gefragt - Lösungen gab es keine :(, so langsam bin ich am verzweifeln. Vllt liegts auch daran, das ich in C++ erst 1 1/2 Wochen schreibe und noch ein Neuling bin.</p>
<p>Lg<br />
Copy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2069325</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2069325</guid><dc:creator><![CDATA[Copykill]]></dc:creator><pubDate>Thu, 26 May 2011 18:42:09 GMT</pubDate></item><item><title><![CDATA[Reply to multiset&amp;lt;struct&amp;gt; - Zugriff auf Elemente? on Thu, 26 May 2011 18:47:01 GMT]]></title><description><![CDATA[<p>Was genau sagt denn dein Compiler zu deinen Versuchen? Wenn ich raten müsste, würde ich sagen, daß er etwas von inkompatiblen Typen sagt - multiset&lt;dataStructure,comp&gt;::iterator ist etwas anderes als multiset&lt;dataStructur&gt;::iterator (letzteres dürfte mangels Vergleichsoperator nicht einmal gültig sein).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2069329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2069329</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 26 May 2011 18:47:01 GMT</pubDate></item><item><title><![CDATA[Reply to multiset&amp;lt;struct&amp;gt; - Zugriff auf Elemente? on Thu, 26 May 2011 18:54:55 GMT]]></title><description><![CDATA[<p>I dunno, hier:<br />
multiset&lt;dataStructure&gt;::iterator</p>
<pre><code class="language-cpp">../timetable.cpp:88:15: error: ‘struct std::multiset&lt;readNsort::dataStructure&gt;::iterator’ has no member named ‘trainId’
../timetable.cpp:88:36: error: ‘struct std::multiset&lt;readNsort::dataStructure&gt;::iterator’ has no member named ‘stationId’
../timetable.cpp:88:59: error: ‘struct std::multiset&lt;readNsort::dataStructure&gt;::iterator’ has no member named ‘arrivalHour’
../timetable.cpp:88:84: error: ‘struct std::multiset&lt;readNsort::dataStructure&gt;::iterator’ has no member named ‘arrivalMinute’
../timetable.cpp:88:111: error: ‘struct std::multiset&lt;readNsort::dataStructure&gt;::iterator’ has no member named ‘descentHour’
../timetable.cpp:88:136: error: ‘struct std::multiset&lt;readNsort::dataStructure&gt;::iterator’ has no member named ‘descentMinute’
../timetable.cpp:88:163: error: ‘struct std::multiset&lt;readNsort::dataStructure&gt;::iterator’ has no member named ‘countDropout’
../timetable.cpp:88:189: error: ‘struct std::multiset&lt;readNsort::dataStructure&gt;::iterator’ has no member named ‘countNewcomer’
</code></pre>
<p>und multiset&lt;dataStructure, comp&gt;::iterator</p>
<pre><code class="language-cpp">../timetable.cpp:88:15: error: ‘struct std::multiset&lt;readNsort::dataStructure, readNsort::comp&gt;::iterator’ has no member named ‘trainId’
../timetable.cpp:88:36: error: ‘struct std::multiset&lt;readNsort::dataStructure, readNsort::comp&gt;::iterator’ has no member named ‘stationId’
../timetable.cpp:88:59: error: ‘struct std::multiset&lt;readNsort::dataStructure, readNsort::comp&gt;::iterator’ has no member named ‘arrivalHour’
../timetable.cpp:88:84: error: ‘struct std::multiset&lt;readNsort::dataStructure, readNsort::comp&gt;::iterator’ has no member named ‘arrivalMinute’
../timetable.cpp:88:111: error: ‘struct std::multiset&lt;readNsort::dataStructure, readNsort::comp&gt;::iterator’ has no member named ‘descentHour’
../timetable.cpp:88:136: error: ‘struct std::multiset&lt;readNsort::dataStructure, readNsort::comp&gt;::iterator’ has no member named ‘descentMinute’
../timetable.cpp:88:163: error: ‘struct std::multiset&lt;readNsort::dataStructure, readNsort::comp&gt;::iterator’ has no member named ‘countDropout’
../timetable.cpp:88:189: error: ‘struct std::multiset&lt;readNsort::dataStructure, readNsort::comp&gt;::iterator’ has no member named ‘countNewcomer’
</code></pre>
<p>/edit: Das ganze ist in ner</p>
<pre><code class="language-cpp">class readNsort
{
private:
...
};
</code></pre>
<p>deklariert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2069334</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2069334</guid><dc:creator><![CDATA[Copykill]]></dc:creator><pubDate>Thu, 26 May 2011 18:54:55 GMT</pubDate></item><item><title><![CDATA[Reply to multiset&amp;lt;struct&amp;gt; - Zugriff auf Elemente? on Thu, 26 May 2011 18:59:19 GMT]]></title><description><![CDATA[<p>Da hast du wohl noch ein Problem mit der Operator-Rangfolge - der Memberzugriff steht höher als die Dereferenzierung, deshalb mußt du das klammern als <code>(*i).trainId</code> (oder du verwendest gleich <code>i-&gt;trainId</code> ).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2069340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2069340</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 26 May 2011 18:59:19 GMT</pubDate></item><item><title><![CDATA[Reply to multiset&amp;lt;struct&amp;gt; - Zugriff auf Elemente? on Thu, 26 May 2011 19:02:43 GMT]]></title><description><![CDATA[<p>Potzblitz vielen Dank, es geht - wunderbar <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="😃"
    /> (Und ich habe schon 2 h daran herumprobiert ;))</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2069342</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2069342</guid><dc:creator><![CDATA[Copykill]]></dc:creator><pubDate>Thu, 26 May 2011 19:02:43 GMT</pubDate></item></channel></rss>