<?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[[Gelöst] Objekte in std::vector speichern, wie geht das?]]></title><description><![CDATA[<p>Wegen</p>
<pre><code>lines&lt;actuallline&gt;.toelements();
</code></pre>
<p>in meinem Code gab es abermillionen von Fehlermeldungen.<br />
Wenn ich lines nicht als vector verwende also</p>
<pre><code>lines.toelements();
</code></pre>
<p>dann funktioniert es, also auch in der Deklaration nicht als vector deklariere.<br />
lines ist ein Objekt von der selbst kreierten Klasse File.<br />
actuallline ist ein interger der im Hauptcode gesetzt ist.<br />
toelements ist eine Methode der Klasse Line also vom Objekt lines.<br />
Ich vermute mal der Fehler kommt daher das std::vector, was ich verwendet habe nicht für Objekte ausgelegt ist.<br />
Wie kann ich eine Beliebige Anzahl Objekte in einem Feld speichern?<br />
Oder liegt es daran das ich für Objekte in einem Vector keine Methoden aufrufen kann, wie kann ich es in dem Fall anders lösen?<br />
Zugegeben ich hab davor noch nie was mit vectoren gemacht, wenn meine Fragen dumm scheinen Sorry.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/323505/gelöst-objekte-in-std-vector-speichern-wie-geht-das</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 22:21:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/323505.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 02 Feb 2014 14:35:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 19:30:15 GMT]]></title><description><![CDATA[<p>Wegen</p>
<pre><code>lines&lt;actuallline&gt;.toelements();
</code></pre>
<p>in meinem Code gab es abermillionen von Fehlermeldungen.<br />
Wenn ich lines nicht als vector verwende also</p>
<pre><code>lines.toelements();
</code></pre>
<p>dann funktioniert es, also auch in der Deklaration nicht als vector deklariere.<br />
lines ist ein Objekt von der selbst kreierten Klasse File.<br />
actuallline ist ein interger der im Hauptcode gesetzt ist.<br />
toelements ist eine Methode der Klasse Line also vom Objekt lines.<br />
Ich vermute mal der Fehler kommt daher das std::vector, was ich verwendet habe nicht für Objekte ausgelegt ist.<br />
Wie kann ich eine Beliebige Anzahl Objekte in einem Feld speichern?<br />
Oder liegt es daran das ich für Objekte in einem Vector keine Methoden aufrufen kann, wie kann ich es in dem Fall anders lösen?<br />
Zugegeben ich hab davor noch nie was mit vectoren gemacht, wenn meine Fragen dumm scheinen Sorry.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2381128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381128</guid><dc:creator><![CDATA[Evolykane]]></dc:creator><pubDate>Sun, 02 Feb 2014 19:30:15 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 14:49:14 GMT]]></title><description><![CDATA[<p>Deine Frage an sich ist nicht dumm, dumm ist, dass du keine Code und keine Fehlermeldungen zeigst!</p>
<pre><code class="language-cpp">class line { ... };
std::vector&lt;line&gt; lines ;
lines.push_back(line());
...
lines[0].toElements()
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2381130</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381130</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sun, 02 Feb 2014 14:49:14 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 14:50:45 GMT]]></title><description><![CDATA[<p>Evolykane schrieb:</p>
<blockquote>
<p>Wegen</p>
<pre><code>lines&lt;actuallline&gt;.toelements();
</code></pre>
<p>in meinem Code gab es abermillionen von Fehlermeldungen.</p>
</blockquote>
<p>Zu recht. Soll das vielleicht <code>lines[actualline].toelements();</code> heißen? BTW aktuell heißt auf Englisch nicht actual, sondern current.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2381132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381132</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Sun, 02 Feb 2014 14:50:45 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 17:26:43 GMT]]></title><description><![CDATA[<p>Bashar schrieb:</p>
<blockquote>
<p>Soll das vielleicht <code>lines[actualline].toelements();</code> heißen?</p>
</blockquote>
<p>Hab ich gerade probiert, funktioniert nicht.<br />
Hier die Klassen die mit dem Vectorproblem zu tun haben.</p>
<pre><code>//file.hpp
#ifndef FILE_HPP_
#define FILE_HPP_
#include &lt;string&gt;
#include &lt;vector&gt;
#include &quot;line.hpp&quot;
class File
{ 
	private:
		std::vector&lt;Line&gt; lines;
		int actuallline;
	public:
		File();
		void takechar(char _zeichen);
};
#endif
</code></pre>
<pre><code>//file.cpp
#include &quot;file.hpp&quot;
#include &quot;line.hpp&quot;
File::File()
{
	actuallline = 0;
}
void File::takechar(char _zeichen)
{
	if(_zeichen == '\n')
	{
		lines&lt;actuallline&gt;.toelements();
		actuallline++;
	}
	else
	{
		lines&lt;actuallline&gt;.takechar(_zeichen);
	}
}
</code></pre>
<pre><code>//line.hpp
#ifndef LINE_HPP_
#define LINE_HPP_
#include &lt;string&gt;
#include &lt;vector&gt;
class Line
{ 
	private:
		std::vector&lt;std::string&gt; elements;
		std::string oldline;
	public:
		void takechar(char _zeichen);
		void toelements();
};
#endif
</code></pre>
<pre><code>//line.cpp
#include &quot;line.hpp&quot;
void Line::takechar(char _zeichen)
{
	oldline += _zeichen;
}
void Line::toelements()
{

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2381158</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381158</guid><dc:creator><![CDATA[Evolykane]]></dc:creator><pubDate>Sun, 02 Feb 2014 17:26:43 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 18:07:43 GMT]]></title><description><![CDATA[<p>Evolykane schrieb:</p>
<blockquote>
<p>Bashar schrieb:</p>
<blockquote>
<p>Soll das vielleicht <code>lines[actualline].toelements();</code> heißen?</p>
</blockquote>
<p>Hab ich gerade probiert, funktioniert nicht.</p>
</blockquote>
<p>Fehlerbeschreibung?</p>
<blockquote>
<p>Hier die Klassen die mit dem Vectorproblem zu tun haben.</p>
</blockquote>
<p>Nichts offensichtliches zu sehen. (Außer natürlich der Blödsinn mit den &lt;...&gt;-Klammern.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2381167</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381167</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Sun, 02 Feb 2014 18:07:43 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 18:17:20 GMT]]></title><description><![CDATA[<p>Errorlog: <a href="http://pastebin.com/ag51B5Tw" rel="nofollow">http://pastebin.com/ag51B5Tw</a><br />
Zu den [] soweit ich weiß sind die eckigen Klammern für Arrays zu benutzen und &lt;&gt; für std::vector weil das ein template ist oder so.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2381170</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381170</guid><dc:creator><![CDATA[Evolykane]]></dc:creator><pubDate>Sun, 02 Feb 2014 18:17:20 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 18:21:40 GMT]]></title><description><![CDATA[<p>Evolykane schrieb:</p>
<blockquote>
<p>soweit ich weiß sind die eckigen Klammern für Arrays zu benutzen und &lt;&gt; für std::vector</p>
</blockquote>
<p>Das ist Unsinn.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2381172</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381172</guid><dc:creator><![CDATA[Caligulaminus]]></dc:creator><pubDate>Sun, 02 Feb 2014 18:21:40 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 18:26:43 GMT]]></title><description><![CDATA[<p>Evolykane schrieb:</p>
<blockquote>
<p>Zu den [] soweit ich weiß sind die eckigen Klammern für Arrays zu benutzen und &lt;&gt; für std::vector weil das ein template ist oder so.</p>
</blockquote>
<p>Na, wenn du alles schon weißt, warum fragst du dann hier? Hier laufen nur die Idioten rum, die [] benutzen würden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2381174</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381174</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sun, 02 Feb 2014 18:26:43 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 18:31:52 GMT]]></title><description><![CDATA[<p>Evolykane schrieb:</p>
<blockquote>
<p>Errorlog: <a href="http://pastebin.com/ag51B5Tw" rel="nofollow">http://pastebin.com/ag51B5Tw</a></p>
</blockquote>
<p>Ich meinte den Fehler, NACHDEM du die &lt;...&gt; durch [...] ersetzt hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2381175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381175</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Sun, 02 Feb 2014 18:31:52 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 18:44:28 GMT]]></title><description><![CDATA[<p><a href="http://pastebin.com/wfs6jn29" rel="nofollow">http://pastebin.com/wfs6jn29</a><br />
Ich mach es dann doch lieber mit Arrays, wie bekommt man die Anzahl der Zeilen einer Datei?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2381179</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381179</guid><dc:creator><![CDATA[Evolykane]]></dc:creator><pubDate>Sun, 02 Feb 2014 18:44:28 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 18:53:53 GMT]]></title><description><![CDATA[<p>Evolykane schrieb:</p>
<blockquote>
<p><a href="http://pastebin.com/wfs6jn29" rel="nofollow">http://pastebin.com/wfs6jn29</a></p>
</blockquote>
<p>Verarschen kann ich mich alleine.</p>
<pre><code>File/file.cpp: In member function ‘void File::takechar(char)’:
File/file.cpp:16:8: error: no match for ‘operator&lt;’ (operand types are ‘std::vector&lt;Line&gt;’ and ‘int’)
   lines&lt;actuallline&gt;.takechar(_zeichen);
        ^
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2381180</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381180</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Sun, 02 Feb 2014 18:53:53 GMT</pubDate></item><item><title><![CDATA[Reply to [Gelöst] Objekte in std::vector speichern, wie geht das? on Sun, 02 Feb 2014 19:03:15 GMT]]></title><description><![CDATA[<p>*facepalm* stimmt ja es waren 2 Methodenaufrufe.<br />
Vielen Dank das du mich darauf aufmerksam gemacht hast, jetzt gibt es keinen Fehler mehr in den beiden Klassen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2381182</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2381182</guid><dc:creator><![CDATA[Evolykane]]></dc:creator><pubDate>Sun, 02 Feb 2014 19:03:15 GMT</pubDate></item></channel></rss>