<?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[Vererbung und static]]></title><description><![CDATA[<p>Hi</p>
<p>ich bastel jetzt schon den halben Mittag an meinem Programm und finde den verdammten Fehler nicht. Auch google ist nicht wirklich hilfreich.</p>
<p>Ich habe folgendes Problem:</p>
<p>Ich habe eine Basisklasse (Interface)<br />
IState:</p>
<pre><code class="language-cpp">/*
 * IState.h
 *
 *  Created on: 03.12.2010
 *      Author: Pascal
 */

#ifndef ISTATE_H_
#define ISTATE_H_

#include &quot;../IAutomat.h&quot;
class IAutomat;

class IState {

protected:
	bool isFinal;

public:
	// IState();
	virtual void read(char c, IAutomat* automat)=0;
	// virtual ~IState();

};

#endif /* ISTATE_H_ */
</code></pre>
<p>Davon erben mehrere State Klassen. ( State0 -State18)<br />
Meine State0 Klasse sieht wie folgt aus:</p>
<pre><code class="language-cpp">/*
 * State0.h
 *
 *  Created on: 03.12.2010
 *      Author: Pascal
 */

#ifndef STATE0_H_
#define STATE0_H_

#include &quot;IState.h&quot;

class State0: public IState{

private:
	static IState* instance;
	State0(void);
	State0(const State0&amp;);
	~State0(void);
public:
	void read(char c, IAutomat* automat);
	static IState&amp; getInstance();
        static void destroy();

};

#endif /* STATE0_H_ */
</code></pre>
<p>Bis jetzt geht auch alles. Sobald ich aber meinen 2ten State anlege:<br />
State1 und dort ebenfalls</p>
<pre><code>#include &quot;IState&quot;
</code></pre>
<p>mache fliegt mir mein kompletter Code um die Ohren. Woran kann das liegen.<br />
Fehlermeldung:</p>
<blockquote>
<p>State0.h:14: error: expected class-name before '{' token<br />
State0.h:17: error: ISO C++ forbids declaration of 'IState' with no type<br />
State0.h:17: error: expected ';' before '*' token<br />
State0.h:22: error: 'IAutomat' has not been declared<br />
State0.h:23: error: ISO C++ forbids declaration of 'IState' with no type<br />
State0.h:23: error: expected ';' before '&amp;' token</p>
</blockquote>
<p>Schon mal im voraus vielen Dank für die Hilfe.</p>
<p>Gruß Passi</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/278380/vererbung-und-static</link><generator>RSS for Node</generator><lastBuildDate>Tue, 25 Aug 2026 06:21:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/278380.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 05 Dec 2010 20:26:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Vererbung und static on Sun, 05 Dec 2010 20:26:58 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>ich bastel jetzt schon den halben Mittag an meinem Programm und finde den verdammten Fehler nicht. Auch google ist nicht wirklich hilfreich.</p>
<p>Ich habe folgendes Problem:</p>
<p>Ich habe eine Basisklasse (Interface)<br />
IState:</p>
<pre><code class="language-cpp">/*
 * IState.h
 *
 *  Created on: 03.12.2010
 *      Author: Pascal
 */

#ifndef ISTATE_H_
#define ISTATE_H_

#include &quot;../IAutomat.h&quot;
class IAutomat;

class IState {

protected:
	bool isFinal;

public:
	// IState();
	virtual void read(char c, IAutomat* automat)=0;
	// virtual ~IState();

};

#endif /* ISTATE_H_ */
</code></pre>
<p>Davon erben mehrere State Klassen. ( State0 -State18)<br />
Meine State0 Klasse sieht wie folgt aus:</p>
<pre><code class="language-cpp">/*
 * State0.h
 *
 *  Created on: 03.12.2010
 *      Author: Pascal
 */

#ifndef STATE0_H_
#define STATE0_H_

#include &quot;IState.h&quot;

class State0: public IState{

private:
	static IState* instance;
	State0(void);
	State0(const State0&amp;);
	~State0(void);
public:
	void read(char c, IAutomat* automat);
	static IState&amp; getInstance();
        static void destroy();

};

#endif /* STATE0_H_ */
</code></pre>
<p>Bis jetzt geht auch alles. Sobald ich aber meinen 2ten State anlege:<br />
State1 und dort ebenfalls</p>
<pre><code>#include &quot;IState&quot;
</code></pre>
<p>mache fliegt mir mein kompletter Code um die Ohren. Woran kann das liegen.<br />
Fehlermeldung:</p>
<blockquote>
<p>State0.h:14: error: expected class-name before '{' token<br />
State0.h:17: error: ISO C++ forbids declaration of 'IState' with no type<br />
State0.h:17: error: expected ';' before '*' token<br />
State0.h:22: error: 'IAutomat' has not been declared<br />
State0.h:23: error: ISO C++ forbids declaration of 'IState' with no type<br />
State0.h:23: error: expected ';' before '&amp;' token</p>
</blockquote>
<p>Schon mal im voraus vielen Dank für die Hilfe.</p>
<p>Gruß Passi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990218</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990218</guid><dc:creator><![CDATA[dit_k]]></dc:creator><pubDate>Sun, 05 Dec 2010 20:26:58 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und static on Sun, 05 Dec 2010 20:32:52 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &quot;IState&quot;
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>oder</p>
<pre><code class="language-cpp">#include &quot;IState.j&quot;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1990220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990220</guid><dc:creator><![CDATA[includierer]]></dc:creator><pubDate>Sun, 05 Dec 2010 20:32:52 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und static on Sun, 05 Dec 2010 20:34:13 GMT]]></title><description><![CDATA[<p>includierer schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#include &quot;IState&quot;
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>oder</p>
<pre><code class="language-cpp">#include &quot;IState.j&quot;
</code></pre>
</blockquote>
<p>Es sollte natürlich</p>
<pre><code class="language-cpp">#include &quot;IState.h&quot;
</code></pre>
<p>heißen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990221</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990221</guid><dc:creator><![CDATA[includierer]]></dc:creator><pubDate>Sun, 05 Dec 2010 20:34:13 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und static on Sun, 05 Dec 2010 20:52:57 GMT]]></title><description><![CDATA[<p>Was für einen Compiler verwendest du? Poste ein kompilierbares Minimalbeispiel, welches sich kompilieren lässt bzw. poste den Code, wo der Fehler auftritt.</p>
<pre><code class="language-cpp">#include &quot;../IAutomat.h&quot;
class IAutomat;
</code></pre>
<p>Was soll das? Wenn du IAutomat.h inkludierst, dann brauchst du auch keine Forward-Deklaration mehr.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990225</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990225</guid><dc:creator><![CDATA[kjkljk]]></dc:creator><pubDate>Sun, 05 Dec 2010 20:52:57 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und static on Mon, 06 Dec 2010 11:59:08 GMT]]></title><description><![CDATA[<p>Wenn ich das <code>#include &quot;../IAutomat.h&quot;</code> entferne, kann ich den Code ohne Probleme kompilieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990367</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990367</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Mon, 06 Dec 2010 11:59:08 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und static on Mon, 06 Dec 2010 13:35:52 GMT]]></title><description><![CDATA[<p>baust du einen (endlichen, whatever) Automaten mit maximal 18 Zuständen? Ich verstehe den Sinn hinter statischen Verpointerung nicht <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="🙂"
    /> wenn du lust hast elaborier doch mal. Ich würde eine &quot;Einmaligkeit&quot; von states allenfalls mittels einer ID festmachen, nicht dafür 18 Klassen die halb Singletons sind herstellen ... deine Fehlermeldungen sprechen dafür dass irgendwas mit dem Inlcude der IState.h nicht funzt - er erkennt das nicht als Klasse weil er nirgend ne Deklaration davon herbekommt. Selbiges gilt für IAutomat.h ... die solltest du -wenn nur vorwärts deklariert- in der State0.h noch includieren da über IState.h da auch nur die Vorwärtsdekl. bekannt ist</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990437</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990437</guid><dc:creator><![CDATA[padreigh]]></dc:creator><pubDate>Mon, 06 Dec 2010 13:35:52 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung und static on Mon, 06 Dec 2010 15:26:56 GMT]]></title><description><![CDATA[<p>padreigh schrieb:</p>
<blockquote>
<p>baust du einen (endlichen, whatever) Automaten mit maximal 18 Zuständen?</p>
</blockquote>
<p><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>
<p>Nee... Mit 19 Zuständen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990537</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990537</guid><dc:creator><![CDATA[_o) _o) _o)]]></dc:creator><pubDate>Mon, 06 Dec 2010 15:26:56 GMT</pubDate></item></channel></rss>