<?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[Foreward declaration von Klassen]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe folgendes Problem:<br />
Ich habe zwei Klassen, die jeweils die andere verwenden.</p>
<pre><code class="language-cpp">#ifndef VPREPROCXS_H_
#define VPREPROCXS_H_
#include &quot;VPreProc.h&quot;
#include &quot;VFileLineXs.h&quot;

#include &lt;deque&gt;

/* Perl */
# include &lt;EXTERN.h&gt;
# include &lt;perl.h&gt;
# include &lt;XSUB.h&gt;

class VFileLineXs;

class VPreProcXs : public VPreProc {
public:
    SV*		m_self;	// Class called from (the hash, not SV pointing to the hash)
    deque&lt;VFileLineXs*&gt; m_filelineps;

    VPreProcXs() : VPreProc() {};
    virtual ~VPreProcXs();

    // Callback methods
    virtual void comment(string filename) {};	// Comment for keepComments=&gt;sub
    virtual void include(string filename){};	// Request a include file be processed
    virtual void define(string name, string value, string params){}; // `define with parameters
    virtual void undef(string name){};		// Remove a definition
    virtual void undefineall(){};			// Remove all non-command-line definitions
    virtual bool defExists(string name);	// Return true if define exists
    virtual string defParams(string name);	// Return parameter list if define exists
    virtual string defValue(string name);	// Return value of given define (should exist)
    virtual string defSubstitute(string substitute);	// Return value to substitute for given post-parameter value

//    void call(string* rtnStrp, int params, const char* method, ...);
    void unreadback(char* text);
};

#endif /* VPREPROCXS_H_ */
</code></pre>
<p>und</p>
<pre><code class="language-cpp">#ifndef VFILELINEXS_H_
#define VFILELINEXS_H_
#include &quot;VFileLine.h&quot;
#include &quot;VPreProcXs.h&quot;

#include &lt;deque&gt;

/* Perl */
# include &lt;EXTERN.h&gt;
# include &lt;perl.h&gt;
# include &lt;XSUB.h&gt;

class VPreProcXs;

class VFileLineXs : public VFileLine {
    VPreProcXs*	m_vPreprocp;		// Parser handling the errors
public:
    VFileLineXs(VPreProcXs* pp) : VFileLine(true), m_vPreprocp(pp) { if (pp) pushFl(); }
    virtual ~VFileLineXs();
    virtual VFileLine* create(const string&amp; filename, int lineno) {
	VFileLineXs* filelp = new VFileLineXs(m_vPreprocp);
	filelp-&gt;init(filename, lineno);
	return filelp;
    }
    virtual void error(const string&amp; msg);	// Report a error at given location
    void setPreproc(VPreProcXs* pp) {
	m_vPreprocp=pp;
	pushFl(); // The very first construction used pp=NULL, as pp wasn't created yet so make it now
    }
    // Record the structure so we can delete it later
    void pushFl() { m_vPreprocp-&gt;m_filelineps.push_back(this); }
};

#endif /* VFILELINEXS_H_ */
</code></pre>
<p>Wenn ich nun mein Programm kompilliere erhalte ich folgenden Fehler:</p>
<pre><code>In file included from Parser/VPreProcXs.h:11:0,
                 from Parser/VPreProcXs.cpp:8:
Parser/VFileLineXs.h: In member function ‘void VFileLineXs::pushFl()’:
Parser/VFileLineXs.h:38:32: error: invalid use of incomplete type ‘struct VPreProcXs’
Parser/VFileLineXs.h:20:7: error: forward declaration of ‘struct VPreProcXs’
</code></pre>
<p>Wie kann ich das umgehen?<br />
Ich verstehe zwar den Fehler, aber nicht wie ich Ihn lösen kann. Meine einzige Idee, wäre beide Klassen in eine Datei zu schreiben und zwar statt der foreward declaration.<br />
Aber das ist ja nicht die schönste Lösung.</p>
<p>Beste Grüße,<br />
JRS</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/305337/foreward-declaration-von-klassen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 09 Aug 2026 01:09:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/305337.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Jun 2012 15:31:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Foreward declaration von Klassen on Tue, 26 Jun 2012 15:31:39 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe folgendes Problem:<br />
Ich habe zwei Klassen, die jeweils die andere verwenden.</p>
<pre><code class="language-cpp">#ifndef VPREPROCXS_H_
#define VPREPROCXS_H_
#include &quot;VPreProc.h&quot;
#include &quot;VFileLineXs.h&quot;

#include &lt;deque&gt;

/* Perl */
# include &lt;EXTERN.h&gt;
# include &lt;perl.h&gt;
# include &lt;XSUB.h&gt;

class VFileLineXs;

class VPreProcXs : public VPreProc {
public:
    SV*		m_self;	// Class called from (the hash, not SV pointing to the hash)
    deque&lt;VFileLineXs*&gt; m_filelineps;

    VPreProcXs() : VPreProc() {};
    virtual ~VPreProcXs();

    // Callback methods
    virtual void comment(string filename) {};	// Comment for keepComments=&gt;sub
    virtual void include(string filename){};	// Request a include file be processed
    virtual void define(string name, string value, string params){}; // `define with parameters
    virtual void undef(string name){};		// Remove a definition
    virtual void undefineall(){};			// Remove all non-command-line definitions
    virtual bool defExists(string name);	// Return true if define exists
    virtual string defParams(string name);	// Return parameter list if define exists
    virtual string defValue(string name);	// Return value of given define (should exist)
    virtual string defSubstitute(string substitute);	// Return value to substitute for given post-parameter value

//    void call(string* rtnStrp, int params, const char* method, ...);
    void unreadback(char* text);
};

#endif /* VPREPROCXS_H_ */
</code></pre>
<p>und</p>
<pre><code class="language-cpp">#ifndef VFILELINEXS_H_
#define VFILELINEXS_H_
#include &quot;VFileLine.h&quot;
#include &quot;VPreProcXs.h&quot;

#include &lt;deque&gt;

/* Perl */
# include &lt;EXTERN.h&gt;
# include &lt;perl.h&gt;
# include &lt;XSUB.h&gt;

class VPreProcXs;

class VFileLineXs : public VFileLine {
    VPreProcXs*	m_vPreprocp;		// Parser handling the errors
public:
    VFileLineXs(VPreProcXs* pp) : VFileLine(true), m_vPreprocp(pp) { if (pp) pushFl(); }
    virtual ~VFileLineXs();
    virtual VFileLine* create(const string&amp; filename, int lineno) {
	VFileLineXs* filelp = new VFileLineXs(m_vPreprocp);
	filelp-&gt;init(filename, lineno);
	return filelp;
    }
    virtual void error(const string&amp; msg);	// Report a error at given location
    void setPreproc(VPreProcXs* pp) {
	m_vPreprocp=pp;
	pushFl(); // The very first construction used pp=NULL, as pp wasn't created yet so make it now
    }
    // Record the structure so we can delete it later
    void pushFl() { m_vPreprocp-&gt;m_filelineps.push_back(this); }
};

#endif /* VFILELINEXS_H_ */
</code></pre>
<p>Wenn ich nun mein Programm kompilliere erhalte ich folgenden Fehler:</p>
<pre><code>In file included from Parser/VPreProcXs.h:11:0,
                 from Parser/VPreProcXs.cpp:8:
Parser/VFileLineXs.h: In member function ‘void VFileLineXs::pushFl()’:
Parser/VFileLineXs.h:38:32: error: invalid use of incomplete type ‘struct VPreProcXs’
Parser/VFileLineXs.h:20:7: error: forward declaration of ‘struct VPreProcXs’
</code></pre>
<p>Wie kann ich das umgehen?<br />
Ich verstehe zwar den Fehler, aber nicht wie ich Ihn lösen kann. Meine einzige Idee, wäre beide Klassen in eine Datei zu schreiben und zwar statt der foreward declaration.<br />
Aber das ist ja nicht die schönste Lösung.</p>
<p>Beste Grüße,<br />
JRS</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2227431</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2227431</guid><dc:creator><![CDATA[JRS]]></dc:creator><pubDate>Tue, 26 Jun 2012 15:31:39 GMT</pubDate></item><item><title><![CDATA[Reply to Foreward declaration von Klassen on Tue, 26 Jun 2012 15:36:15 GMT]]></title><description><![CDATA[<p>Brauchst du</p>
<pre><code class="language-cpp">#include &quot;VFileLineXs.h&quot;
</code></pre>
<p>bei der ersten Klasse? Die Vorwärtsdeklaration sollte doch ausreichen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2227433</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2227433</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Tue, 26 Jun 2012 15:36:15 GMT</pubDate></item><item><title><![CDATA[Reply to Foreward declaration von Klassen on Tue, 26 Jun 2012 15:43:12 GMT]]></title><description><![CDATA[<p>Die Fehlermeldung passt nicht zum gezeigten Code. VFileLineXs.h hat keine 38 Zeilen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2227435</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2227435</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 26 Jun 2012 15:43:12 GMT</pubDate></item><item><title><![CDATA[Reply to Foreward declaration von Klassen on Tue, 26 Jun 2012 15:50:32 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>danke. Ich werde mal weiter sehen. der komplette Code ist:</p>
<pre><code class="language-cpp">/*
 * VFileLineXs.h
 *
 *  Created on: 30.04.2012
 *      Author: jseyler
 */

#ifndef VFILELINEXS_H_
#define VFILELINEXS_H_
#include &quot;VFileLine.h&quot;
#include &quot;VPreProcXs.h&quot;

#include &lt;deque&gt;

/* Perl */
# include &lt;EXTERN.h&gt;
# include &lt;perl.h&gt;
# include &lt;XSUB.h&gt;

class VPreProcXs;

class VFileLineXs : public VFileLine {
    VPreProcXs*	m_vPreprocp;		// Parser handling the errors
public:
    VFileLineXs(VPreProcXs* pp) : VFileLine(true), m_vPreprocp(pp) { if (pp) pushFl(); }
    virtual ~VFileLineXs();
    virtual VFileLine* create(const string&amp; filename, int lineno) {
	VFileLineXs* filelp = new VFileLineXs(m_vPreprocp);
	filelp-&gt;init(filename, lineno);
	return filelp;
    }
    virtual void error(const string&amp; msg);	// Report a error at given location
    void setPreproc(VPreProcXs* pp) {
	m_vPreprocp=pp;
	pushFl(); // The very first construction used pp=NULL, as pp wasn't created yet so make it now
    }
    // Record the structure so we can delete it later
    void pushFl() { m_vPreprocp-&gt;m_filelineps.push_back(this); }
};

#endif /* VFILELINEXS_H_ */
</code></pre>
<p>Dann kommt man auch auf die lines. Auch beim anderen Code ist nochmal ne Präambel davor.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2227441</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2227441</guid><dc:creator><![CDATA[JRS]]></dc:creator><pubDate>Tue, 26 Jun 2012 15:50:32 GMT</pubDate></item><item><title><![CDATA[Reply to Foreward declaration von Klassen on Tue, 26 Jun 2012 15:54:34 GMT]]></title><description><![CDATA[<p>Jetzt passt es zusammen. Und Bashar hat ja die Lösung schon vorgegeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2227443</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2227443</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 26 Jun 2012 15:54:34 GMT</pubDate></item><item><title><![CDATA[Reply to Foreward declaration von Klassen on Tue, 26 Jun 2012 15:59:50 GMT]]></title><description><![CDATA[<p>Mach die zyklische Abhängigkeit der Header weg und lagere wenigstens die Implementierung der Methoden (aka Elementfunktionsdefinitionen), die die vollständigen Klassendefinitionen benötigen, in entsprechende cpp-Dateien aus, in der du dann jeweils beide Header inkludierst.</p>
<p>Aber ... mal ehrlich gesagt ... so richtig dolle wirkt das Design jetzt nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2227447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2227447</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Tue, 26 Jun 2012 15:59:50 GMT</pubDate></item><item><title><![CDATA[Reply to Foreward declaration von Klassen on Tue, 26 Jun 2012 16:11:13 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe natürlich auch noch zwei entsprechende CPP-Klassen mit den Definitionen. Die wollte ich nicht auch noch hier posten.</p>
<p>Und das Design ist tatsächlich nicht sehr hübsch. Habe es so komplett übernommen und versuche es nur erstmal zum Laufen zu bringen <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>
<p>Vielen Dank!<br />
Beste Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2227454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2227454</guid><dc:creator><![CDATA[JRS]]></dc:creator><pubDate>Tue, 26 Jun 2012 16:11:13 GMT</pubDate></item><item><title><![CDATA[Reply to Foreward declaration von Klassen on Tue, 26 Jun 2012 17:44:21 GMT]]></title><description><![CDATA[<p>Wobei ich natürlich für alle Verbesserungsvorschläge und Anregungen immer sehr dankbar bin <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="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2227486</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2227486</guid><dc:creator><![CDATA[JRS]]></dc:creator><pubDate>Tue, 26 Jun 2012 17:44:21 GMT</pubDate></item></channel></rss>