<?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[Es fehlt &#x27;;&#x27; vor &#x27;*&#x27; ... Wirklich? [gelöst]]]></title><description><![CDATA[<p>Hi,</p>
<p>ich bin gerade dabei Listen für ein Rechenprogramm zu implementieren.<br />
Dabei kommt immer folgende Fehlermeldung:</p>
<blockquote>
<p>error C2143: Syntaxfehler: Es fehlt ';' vor '*'</p>
</blockquote>
<p>und einige Folgefehler.</p>
<p>Es geht um die Zeile 48:</p>
<pre><code>sItem* cList::GetLastItem()
</code></pre>
<p>(Ist unten auch markiert)</p>
<p>Sieht Jemand, wo das ';' fehlt, oder ob es vlt einen anderen Grund hat?</p>
<pre><code>namespace ListHandler {

	public class cList
	{
	public:
		struct sItem
		{
			float Value;

			sItem* NextItem;
		};

		cList(float fValue);
		~cList();

		void AddItem(float Value);
		sItem* GetLastItem(void);
		float GetItem(int ItemIndex);
		void ClearList(void);

	private:
		sItem ListHeader;

	};

	cList::cList(float fValue)	
	{	
		ListHeader.Value = fValue;
	}

	cList::~cList()	
	{	
		cList::ClearList();
	}

	float cList::GetItem(int ItemIndex)
	{
		sItem* NewItem = &amp;ListHeader;

		for (int i = 0; i &lt; ItemIndex - 1; i++)
		{
			NewItem = NewItem-&gt;NextItem;
		}

		return NewItem-&gt;Value;
	}

	sItem* cList::GetLastItem()     //Fehler tritt hier auf
	{
		sItem* nextItem = &amp;ListHeader;

		while(NULL != nextItem-&gt;NextItem)
		{
			nextItem = nextItem-&gt;NextItem;
		}

		return nextItem;
	}

//	...  code geht noch weiter

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/272916/es-fehlt-vor-wirklich-gelöst</link><generator>RSS for Node</generator><lastBuildDate>Fri, 28 Aug 2026 11:36:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/272916.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 27 Aug 2010 14:50:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Es fehlt &#x27;;&#x27; vor &#x27;*&#x27; ... Wirklich? [gelöst] on Fri, 27 Aug 2010 14:57:27 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich bin gerade dabei Listen für ein Rechenprogramm zu implementieren.<br />
Dabei kommt immer folgende Fehlermeldung:</p>
<blockquote>
<p>error C2143: Syntaxfehler: Es fehlt ';' vor '*'</p>
</blockquote>
<p>und einige Folgefehler.</p>
<p>Es geht um die Zeile 48:</p>
<pre><code>sItem* cList::GetLastItem()
</code></pre>
<p>(Ist unten auch markiert)</p>
<p>Sieht Jemand, wo das ';' fehlt, oder ob es vlt einen anderen Grund hat?</p>
<pre><code>namespace ListHandler {

	public class cList
	{
	public:
		struct sItem
		{
			float Value;

			sItem* NextItem;
		};

		cList(float fValue);
		~cList();

		void AddItem(float Value);
		sItem* GetLastItem(void);
		float GetItem(int ItemIndex);
		void ClearList(void);

	private:
		sItem ListHeader;

	};

	cList::cList(float fValue)	
	{	
		ListHeader.Value = fValue;
	}

	cList::~cList()	
	{	
		cList::ClearList();
	}

	float cList::GetItem(int ItemIndex)
	{
		sItem* NewItem = &amp;ListHeader;

		for (int i = 0; i &lt; ItemIndex - 1; i++)
		{
			NewItem = NewItem-&gt;NextItem;
		}

		return NewItem-&gt;Value;
	}

	sItem* cList::GetLastItem()     //Fehler tritt hier auf
	{
		sItem* nextItem = &amp;ListHeader;

		while(NULL != nextItem-&gt;NextItem)
		{
			nextItem = nextItem-&gt;NextItem;
		}

		return nextItem;
	}

//	...  code geht noch weiter

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1945084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1945084</guid><dc:creator><![CDATA[KillerPille]]></dc:creator><pubDate>Fri, 27 Aug 2010 14:57:27 GMT</pubDate></item><item><title><![CDATA[Reply to Es fehlt &#x27;;&#x27; vor &#x27;*&#x27; ... Wirklich? [gelöst] on Fri, 27 Aug 2010 14:53:06 GMT]]></title><description><![CDATA[<p>Es müsste cList::sItem* heißen.<br />
Warum benutzt du nicht std::list?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1945087</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1945087</guid><dc:creator><![CDATA[Nukularfüsiker]]></dc:creator><pubDate>Fri, 27 Aug 2010 14:53:06 GMT</pubDate></item><item><title><![CDATA[Reply to Es fehlt &#x27;;&#x27; vor &#x27;*&#x27; ... Wirklich? [gelöst] on Fri, 27 Aug 2010 14:57:00 GMT]]></title><description><![CDATA[<p>thx für die schnelle antwort</p>
<p>Ich studiere ab dem nächsten monat softwaretechnik und diese listen kommen auch irgendwann dran. Deshalb schau ich sie mir lieber jetzt genauer an. Selbermachen ist besser als fertiges nutzen <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/1945091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1945091</guid><dc:creator><![CDATA[KillerPille]]></dc:creator><pubDate>Fri, 27 Aug 2010 14:57:00 GMT</pubDate></item><item><title><![CDATA[Reply to Es fehlt &#x27;;&#x27; vor &#x27;*&#x27; ... Wirklich? [gelöst] on Fri, 27 Aug 2010 15:02:20 GMT]]></title><description><![CDATA[<p>KillerPille schrieb:</p>
<blockquote>
<p>Ich studiere ab dem nächsten monat softwaretechnik und diese listen kommen auch irgendwann dran. Deshalb schau ich sie mir lieber jetzt genauer an.</p>
</blockquote>
<p>Das akzeptiere ich...</p>
<p>KillerPille schrieb:</p>
<blockquote>
<p>Selbermachen ist besser als fertiges nutzen <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>Aber diese Aussage ist im Softwareumfeld, bei dem es auch um Entwicklungszeit geht, einfach Unsinn.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1945093</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1945093</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Fri, 27 Aug 2010 15:02:20 GMT</pubDate></item><item><title><![CDATA[Reply to Es fehlt &#x27;;&#x27; vor &#x27;*&#x27; ... Wirklich? [gelöst] on Fri, 27 Aug 2010 15:06:23 GMT]]></title><description><![CDATA[<p>asc schrieb:</p>
<blockquote>
<p>KillerPille schrieb:</p>
<blockquote>
<p>Selbermachen ist besser als fertiges nutzen <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>Aber diese Aussage ist im Softwareumfeld, bei dem es auch um Entwicklungszeit geht, einfach Unsinn.</p>
</blockquote>
<p>Es geht mir dabei ums Lernen. Und im Moment habe ich ja noch Zeit dafür.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1945097</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1945097</guid><dc:creator><![CDATA[KillerPille]]></dc:creator><pubDate>Fri, 27 Aug 2010 15:06:23 GMT</pubDate></item><item><title><![CDATA[Reply to Es fehlt &#x27;;&#x27; vor &#x27;*&#x27; ... Wirklich? [gelöst] on Fri, 27 Aug 2010 15:32:39 GMT]]></title><description><![CDATA[<p>KillerPille schrieb:</p>
<blockquote>
<p>asc schrieb:</p>
<blockquote>
<p>KillerPille schrieb:</p>
<blockquote>
<p>Selbermachen ist besser als fertiges nutzen <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>Aber diese Aussage ist im Softwareumfeld, bei dem es auch um Entwicklungszeit geht, einfach Unsinn.</p>
</blockquote>
<p>Es geht mir dabei ums Lernen. Und im Moment habe ich ja noch Zeit dafür.</p>
</blockquote>
<p>Das hat er ja auch akzeptiert und wir alle finden das vollkommen in Ordnung. Er wollte dir damit nur sagen, dass das aber später im &quot;echten Leben&quot; so nicht mehr gemacht wird bzw. werden kann, weil einfach die Zeit fehlt. Man muss es schließlich nicht nur programmieren, sondern auch planen und genaustens testen. Da ist man mit fertigen Klassen, die es schon über Jahre hinweg gibt besser dran.</p>
<p>Hast du das Problem jetzt gelöst? Der Titel deutet das zumindest an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1945110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1945110</guid><dc:creator><![CDATA[nnnn]]></dc:creator><pubDate>Fri, 27 Aug 2010 15:32:39 GMT</pubDate></item><item><title><![CDATA[Reply to Es fehlt &#x27;;&#x27; vor &#x27;*&#x27; ... Wirklich? [gelöst] on Fri, 27 Aug 2010 15:37:04 GMT]]></title><description><![CDATA[<p>Deine Funktion GetItem ist übrigens insofern kritisch, dass sie abstürzt, wenn man einen Index übergibt, der nicht existiert.</p>
<pre><code class="language-cpp">for (int i = 0; i &lt; ItemIndex - 1; i++)
{
 if (!NewItem)
 {
  break;
 }

 NewItem = NewItem-&gt;NextItem;
}
</code></pre>
<p>Ungetestet, aber vermutlich besser.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1945112</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1945112</guid><dc:creator><![CDATA[nnn]]></dc:creator><pubDate>Fri, 27 Aug 2010 15:37:04 GMT</pubDate></item><item><title><![CDATA[Reply to Es fehlt &#x27;;&#x27; vor &#x27;*&#x27; ... Wirklich? [gelöst] on Sat, 28 Aug 2010 11:11:39 GMT]]></title><description><![CDATA[<p>KillerPille schrieb:</p>
<blockquote>
<pre><code class="language-cpp">namespace ListHandler {

	/*public*/ class cList //das public hat hier nix zu suchen
	{
	public:
		struct sItem
		{
			float Value;

			sItem* NextItem;
		};
		
		cList(float fValue);
		~cList();

		void AddItem(float Value);
		sItem* GetLastItem(/*void*/); //es ist unüblich in C++ (void) zu schreiben - man schreibt statt dessen ()
		float GetItem(int ItemIndex) /**/const/**/; //google mal nach const correctness
		void ClearList(void);

	private:
		/*sItem ListHeader;*/ //wie möchtest du so eine leere Liste bewerkstelligen? Wenn ich du wäre, würde ich einen Pointer auf das erste Element speichern:
		sItem* ListHeader;
	};

	cList::cList(float fValue)	
	{	
		ListHeader.Value = fValue;
	}

	cList::~cList()	
	{	
		/*cList::*/ClearList();
	}

	float cList::GetItem(int ItemIndex)
	{
		sItem* NewItem = &amp;ListHeader;

		for (int i = 0; i &lt; ItemIndex - 1; i++)
		{
			NewItem = NewItem-&gt;NextItem; //noch auf 0/NULL/nullptr testen, sonst gibts nen Knall, wenn der Benutzer nicht aufpasst
		}

		return NewItem-&gt;Value;
	}

	sItem* cList::GetLastItem()     //Fehler tritt hier auf
	{
		sItem* nextItem = &amp;ListHeader;

		while(NULL != nextItem-&gt;NextItem)
		{
			nextItem = nextItem-&gt;NextItem;
		}

		return nextItem;
	}
	
//	...  code geht noch weiter

}
</code></pre>
</blockquote>
<p>bb</p>
<p>PS: ungarische Notation ist out - das gilt ins besondere für Bezeichner wie sItem oder cList - 1. ist es unwichtig 2. einfach nur hässlich</p>
<p>ich würde so anfangen:</p>
<pre><code class="language-cpp">/*header*/
class list
{
public:
  list();
  ~list();
  clear();

  void push_front(float val);
private:
  struct item;
  item* first;
};
</code></pre>
<pre><code class="language-cpp">/*source*/
struct list::item
{
  float val;
  item* next;

  item(float val = 0.f, item* next = NULL)
  : val(val), next(next)
  {}
};

list::list()
: first(NULL)
{}

list::~list()
{
  clear();
}

list::clear()
{
  item* i(first);
  while(i != 0)
  {
    item* to_del = i;
    i = i-&gt;next;

    delete to_del;
  };
}

list::push_front(float val)
{
  item* to_add = new item(val, first);
  first = to_add;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1945329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1945329</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 28 Aug 2010 11:11:39 GMT</pubDate></item><item><title><![CDATA[Reply to Es fehlt &#x27;;&#x27; vor &#x27;*&#x27; ... Wirklich? [gelöst] on Mon, 30 Aug 2010 08:35:09 GMT]]></title><description><![CDATA[<p>vielen Dank für die Tipps<br />
gut, dass ich mich jetzt damit beschäftige <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=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1946018</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1946018</guid><dc:creator><![CDATA[KillerPille]]></dc:creator><pubDate>Mon, 30 Aug 2010 08:35:09 GMT</pubDate></item></channel></rss>