<?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[error C2062: type &#x27;int&#x27; unexpected]]></title><description><![CDATA[<p>Hallo ich bekomme folgende Fehler und weiß nicht wo die Ursache dafür liegt :</p>
<pre><code>edge.h : error C2062: type 'int' unexpected
edge.h : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
edge.h : error C2061: syntax error : identifier 'Vertex'
</code></pre>
<p>Hier mein Quelltext zu edge.h :</p>
<pre><code>#ifndef _MYEDGE_
#define _MYEDGE_

#include &quot;base.h&quot;
#include &quot;vertex.h&quot;
using namespace std;

class Edge : public Base 
{

private:
	int length;

public:
	//Leerer Konstruktor
	Edge() : Base()
	{
		this-&gt;setLength(0);
	};

HIER MECKERT ER ÜBER DEN INT WERT :
	Edge(int edgelength,Vertex* vtx=PSEUDO,Edge* nedge=PSEUDO) : Base(vtx,nedge)
	{
		this-&gt;setLength(edgelength);
	};

	//Kopierkonstruktor
	Edge(Edge* e) : Base( ((Vertex*)(e-&gt;getBaseOne())) , ((Edge*)(e-&gt;getBaseTwo())) )
	{
		this-&gt;setLength(e-&gt;getLength());
	};

	//Gibt die Vertex zurück, auf die diese Ecke hinläuft
	Edge* getVertex()
	{
		return (Vertex*)this-&gt;getBaseOne();
	};

HIER MECKERT ER ÜBER DEN IDENTIFIER VERTEX :
	//Setzt die Vertex, auf die diese Ecke hinläuft
	void setVertex(Vertex* toset)
	{
		this-&gt;setBaseOne(toset);
	};

	//Gibt die nächste Edge zurück
	Edge* getEdge()
	{
		return (Edge*)this-&gt;getBaseTwo();
	};

	//Setzt die nächste Edge
	void setEdge(Edge* etwo)
	{
		this-&gt;setBaseTwo(etwo);
	};

	//Gibt das Gewicht bzw. die Länge der Edge zurück
	int getLength()
	{
		return this-&gt;length;
	};

	//Setzt das Gewicht bzw. die Länge der Edge
	void setLength(int length)
	{
		this-&gt;length = length;
	};
};
#endif
</code></pre>
<p>Vertex</p>
<pre><code>#ifndef _MYVERTEX_
#define _MYVERTEX_

#include &quot;base.h&quot;
#include &quot;edge.h&quot;
using namespace std;

class Vertex : public Base {

private:
	string cityname;

public:
	Vertex() : Base(){
		cityname = &quot;&quot;;
	};

	Vertex(string cityname) : Base(){
		this-&gt;setCityName(cityname);
	};

	Vertex(Vertex* v) : Base(v-&gt;getNextVertex(),v-&gt;getEdge()){
		this-&gt;setCityName(v-&gt;getCityName());
	};

	Vertex* getNextVertex(){
		return (Vertex*)getBaseOne();
	};

	Edge* getEdge(){
		return (Edge*)getBaseTwo();
	};

	Edge* getEdge(int i){
		Edge* current = this-&gt;getEdge();
		for(int k=0;k&lt;i;k++)
		{
			current = current-&gt;getEdge();
			if(current == PSEUDO)
				return PSEUDO;
		}

		return current;
	};

	string getCityName(){
		return this-&gt;cityname;
	};

	void setCityName(string name){
		this-&gt;cityname = name;
	};

	void addToEdgeList(Edge* atel){

	};

	void setVertex(Vertex* vlr){
		this-&gt;setBaseOne(vlr);
	};

	void setEdgeRoot(Edge* elr){
		this-&gt;setBaseTwo(elr);
	};
};

#endif
</code></pre>
<p>Base</p>
<pre><code>#ifndef _MY_BASE_
#define _MY_BASE_

#define PSEUDO NULL
using namespace std;

class Base
{

private:
	Base* one;
	Base* two;

public:
	Base(){
		one = PSEUDO; two = PSEUDO;
	};

	Base(Base* one,Base* two){
		this-&gt;one = one; this-&gt;two = two;
	};

	~Base(){
	};

	Base* getBaseOne(){
		return one;
	};
	Base* getBaseTwo(){
		return two;
	};

	void setBaseOne(Base* one){
		this-&gt;one = one;
	};
	void setBaseTwo(Base* two){
		this-&gt;two = two;
	};
};

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/125921/error-c2062-type-int-unexpected</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 13:57:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/125921.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Nov 2005 13:58:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:23:57 GMT]]></title><description><![CDATA[<p>Hallo ich bekomme folgende Fehler und weiß nicht wo die Ursache dafür liegt :</p>
<pre><code>edge.h : error C2062: type 'int' unexpected
edge.h : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
edge.h : error C2061: syntax error : identifier 'Vertex'
</code></pre>
<p>Hier mein Quelltext zu edge.h :</p>
<pre><code>#ifndef _MYEDGE_
#define _MYEDGE_

#include &quot;base.h&quot;
#include &quot;vertex.h&quot;
using namespace std;

class Edge : public Base 
{

private:
	int length;

public:
	//Leerer Konstruktor
	Edge() : Base()
	{
		this-&gt;setLength(0);
	};

HIER MECKERT ER ÜBER DEN INT WERT :
	Edge(int edgelength,Vertex* vtx=PSEUDO,Edge* nedge=PSEUDO) : Base(vtx,nedge)
	{
		this-&gt;setLength(edgelength);
	};

	//Kopierkonstruktor
	Edge(Edge* e) : Base( ((Vertex*)(e-&gt;getBaseOne())) , ((Edge*)(e-&gt;getBaseTwo())) )
	{
		this-&gt;setLength(e-&gt;getLength());
	};

	//Gibt die Vertex zurück, auf die diese Ecke hinläuft
	Edge* getVertex()
	{
		return (Vertex*)this-&gt;getBaseOne();
	};

HIER MECKERT ER ÜBER DEN IDENTIFIER VERTEX :
	//Setzt die Vertex, auf die diese Ecke hinläuft
	void setVertex(Vertex* toset)
	{
		this-&gt;setBaseOne(toset);
	};

	//Gibt die nächste Edge zurück
	Edge* getEdge()
	{
		return (Edge*)this-&gt;getBaseTwo();
	};

	//Setzt die nächste Edge
	void setEdge(Edge* etwo)
	{
		this-&gt;setBaseTwo(etwo);
	};

	//Gibt das Gewicht bzw. die Länge der Edge zurück
	int getLength()
	{
		return this-&gt;length;
	};

	//Setzt das Gewicht bzw. die Länge der Edge
	void setLength(int length)
	{
		this-&gt;length = length;
	};
};
#endif
</code></pre>
<p>Vertex</p>
<pre><code>#ifndef _MYVERTEX_
#define _MYVERTEX_

#include &quot;base.h&quot;
#include &quot;edge.h&quot;
using namespace std;

class Vertex : public Base {

private:
	string cityname;

public:
	Vertex() : Base(){
		cityname = &quot;&quot;;
	};

	Vertex(string cityname) : Base(){
		this-&gt;setCityName(cityname);
	};

	Vertex(Vertex* v) : Base(v-&gt;getNextVertex(),v-&gt;getEdge()){
		this-&gt;setCityName(v-&gt;getCityName());
	};

	Vertex* getNextVertex(){
		return (Vertex*)getBaseOne();
	};

	Edge* getEdge(){
		return (Edge*)getBaseTwo();
	};

	Edge* getEdge(int i){
		Edge* current = this-&gt;getEdge();
		for(int k=0;k&lt;i;k++)
		{
			current = current-&gt;getEdge();
			if(current == PSEUDO)
				return PSEUDO;
		}

		return current;
	};

	string getCityName(){
		return this-&gt;cityname;
	};

	void setCityName(string name){
		this-&gt;cityname = name;
	};

	void addToEdgeList(Edge* atel){

	};

	void setVertex(Vertex* vlr){
		this-&gt;setBaseOne(vlr);
	};

	void setEdgeRoot(Edge* elr){
		this-&gt;setBaseTwo(elr);
	};
};

#endif
</code></pre>
<p>Base</p>
<pre><code>#ifndef _MY_BASE_
#define _MY_BASE_

#define PSEUDO NULL
using namespace std;

class Base
{

private:
	Base* one;
	Base* two;

public:
	Base(){
		one = PSEUDO; two = PSEUDO;
	};

	Base(Base* one,Base* two){
		this-&gt;one = one; this-&gt;two = two;
	};

	~Base(){
	};

	Base* getBaseOne(){
		return one;
	};
	Base* getBaseTwo(){
		return two;
	};

	void setBaseOne(Base* one){
		this-&gt;one = one;
	};
	void setBaseTwo(Base* two){
		this-&gt;two = two;
	};
};

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/913936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913936</guid><dc:creator><![CDATA[Themaximum]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:23:57 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:03:05 GMT]]></title><description><![CDATA[<p>hinter einer Funktion (in dem Fall der Default-Ctor) gehört eigentlich kein ;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913941</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913941</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:03:05 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:11:16 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>hinter einer Funktion (in dem Fall der Default-Ctor) gehört eigentlich kein ;</p>
</blockquote>
<p>es ist nicht notwendig, aber auch kein fehler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913947</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913947</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:11:16 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:12:23 GMT]]></title><description><![CDATA[<p>Möglicherweise fehlt aber in einer der anderen Dateien ein Semikolon am Ende einer Klassendeklaration.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913948</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913948</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:12:23 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:22:28 GMT]]></title><description><![CDATA[<p>MFK schrieb:</p>
<blockquote>
<p>Möglicherweise fehlt aber in einer der anderen Dateien ein Semikolon am Ende einer Klassendeklaration.</p>
</blockquote>
<p>Ich denke nicht...<br />
Ich poste mal die anderen Files</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913958</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913958</guid><dc:creator><![CDATA[Themaximum]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:22:28 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:26:33 GMT]]></title><description><![CDATA[<p>vertex.h und edge.h binden sich gegenseitig ein. Das funktioniert nicht. Ich denke, in vertex.h sollten auch Vorwärtsdeklarationen von Base und Edge ausreichen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913965</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913965</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:26:33 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:33:43 GMT]]></title><description><![CDATA[<p>MFK schrieb:</p>
<blockquote>
<p>vertex.h und edge.h binden sich gegenseitig ein. Das funktioniert nicht. Ich denke, in vertex.h sollten auch Vorwärtsdeklarationen von Base und Edge ausreichen.</p>
</blockquote>
<p>Wie meinst du soll ich nun einbinden ?<br />
in vertex.h : base.h und edge.h<br />
und in edge.h : nur base.h ?</p>
<p>Aber edge.h &quot;weiß&quot; doch dann garnichts von Vertex , obwohl er Pointer darauf zurückgibt.</p>
<p>Das hab ich jetzt mal so gemacht und bekomme die gleichen Fehler</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913981</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913981</guid><dc:creator><![CDATA[Themaximum]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:33:43 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:36:57 GMT]]></title><description><![CDATA[<p>dazu eine vorwärtsdeklaration von vertex</p>
<pre><code class="language-cpp">class Vertex;
</code></pre>
<p>in edge.h</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913988</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913988</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:36:57 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:39:31 GMT]]></title><description><![CDATA[<p>Bei Pointern ist keine Definition nötig, kannst auch die Header weg lassen. Muß nur ne Forward-Deklaration da sein, da ein Pointer immer gleich groß ist, braucht der Compiler die Informationen des Typs nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913993</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:39:31 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:42:06 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>dazu eine vorwärtsdeklaration von vertex</p>
<pre><code class="language-cpp">class Vertex;
</code></pre>
<p>in edge.h</p>
</blockquote>
<p>Jetzt bringt er das :</p>
<pre><code>edge.h(26) : error C2664: 'Base::Base(Base *,Base *)' : cannot convert parameter 1 from 'Vertex *' to 'Base *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
edge.h(32) : error C2664: 'Base::Base(Base *,Base *)' : cannot convert parameter 1 from 'Vertex *' to 'Base *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
edge.h(45) : error C2664: 'Base::setBaseOne' : cannot convert parameter 1 from 'Vertex *' to 'Base *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
</code></pre>
<p>Kenne mich mit dem vorwärtscast wie du es sagst wohl nicht wirklich aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914000</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914000</guid><dc:creator><![CDATA[Themaximum]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:42:06 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 14:45:08 GMT]]></title><description><![CDATA[<p>stimmt, für konversionen von derived nach base muss er die definition von derived (also vertex) schon mal gesehen haben. du müsstest folglich die funktionen ausserhalb der klassendefinion definieren nachdem du vertex.h eingebunden hast. evtl. liegt hier auch ein designfehler vor.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914006</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 10 Nov 2005 14:45:08 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Thu, 10 Nov 2005 17:57:43 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>stimmt, für konversionen von derived nach base muss er die definition von derived (also vertex) schon mal gesehen haben. du müsstest folglich die funktionen ausserhalb der klassendefinion definieren nachdem du vertex.h eingebunden hast. evtl. liegt hier auch ein designfehler vor.</p>
</blockquote>
<p>Also an einen Designfehler glaub ich nicht :</p>
<p>Also ich versuche mal zu erklären was ich so bezwecke :</p>
<p>Das ganze soll wie viele warscheindlich schon gemerkt haben ein graph werden (nur Übung macht den Meister *gg*).<br />
Base ist die Basisklasse zu Vertex und Edge<br />
Jeder Vertex hat einen Pointer auf eine Ecke(Eckenliste) und einen Pointer auf eine Kante (Also eine Kantenliste).<br />
Die Ecke wiederum hat einen Pointer auf eine Ecke und eine Kante.</p>
<p>graph -&gt; Vertex1 -&gt; Vertex2 -&gt; Vertex3<br />
Vertex1 -&gt;Edge1<br />
Edge1 -&gt; Vertex2 und Edge1 -&gt; Edge2</p>
<p>Vertex2 -&gt; Edge1<br />
Edge1 -&gt; Vertex1 und Ege1 -&gt; Edge3<br />
usw.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914179</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914179</guid><dc:creator><![CDATA[Themaximum]]></dc:creator><pubDate>Thu, 10 Nov 2005 17:57:43 GMT</pubDate></item><item><title><![CDATA[Reply to error C2062: type &#x27;int&#x27; unexpected on Sat, 12 Nov 2005 07:45:36 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>stimmt, für konversionen von derived nach base muss er die definition von derived (also vertex) schon mal gesehen haben. du müsstest folglich die funktionen ausserhalb der klassendefinion definieren nachdem du vertex.h eingebunden hast. evtl. liegt hier auch ein designfehler vor.</p>
</blockquote>
<p>Also ich hab jetzt mal noch was umgeschrieben und hab Vertex* und/oder Edge* durch Base* ersetzt.</p>
<p>So lässt es sich wenigstens kompilieren.<br />
Dies ist aber irgendwie wenig zufriedenstellend</p>
<p>edge.h</p>
<pre><code>#ifndef _MYEDGE_
#define _MYEDGE_

#include &quot;base.h&quot;
using namespace std;

class Edge : public Base {

private:
	int length;

public:
	//Leerer Konstruktor
	Edge() : Base()
	{
		this-&gt;setLength(0);
	};

	//Konstruktor um eine Edge mit einer Länge anzulegen
	Edge(int edgelength,Edge* vtx=PSEUDO,Edge* nedge=PSEUDO) : Base(vtx,nedge)
	{
		this-&gt;setLength(edgelength);
	};

	//Kopierkonstruktor
	Edge(Edge* e) : Base( ((Vertex*)(e-&gt;getBaseOne())) , ((Edge*)(e-&gt;getBaseTwo())) )
	{
		this-&gt;setLength(e-&gt;getLength());
	};

	//Gibt die Vertex zurück, auf die diese Ecke hinläuft
	Vertex* getVertex()
	{
		return (Vertex*)this-&gt;getBaseOne();
	};

	//Setzt die Vertex, auf die diese Ecke hinläuft
	void setVertex(Vertex* toset)
	{
		this-&gt;setBaseOne(toset);
	};

	//Gibt die nächste Edge zurück
	Edge* getEdge()
	{
		return (Edge*)this-&gt;getBaseTwo();
	};

	//Setzt die nächste Edge
	void setEdge(Edge* etwo)
	{
		this-&gt;setBaseTwo(etwo);
	};

	//Gibt das Gewicht bzw. die Länge der Edge zurück
	int getLength()
	{
		return this-&gt;length;
	};

	//Setzt das Gewicht bzw. die Länge der Edge
	void setLength(int length)
	{
		this-&gt;length = length;
	};
};

#endif
</code></pre>
<p>vertex.h</p>
<pre><code>#ifndef _MYVERTEX_
#define _MYVERTEX_

#include &quot;base.h&quot;
using namespace std;

class Vertex : public Base {

private:
	string cityname;

public:
	Vertex() : Base(){
		cityname = &quot;&quot;;
	};

	Vertex(string cityname) : Base(){
		this-&gt;setCityName(cityname);
	};

	Vertex(Vertex* v) : Base(v-&gt;getNextVertex(),v-&gt;getEdge()){
		this-&gt;setCityName(v-&gt;getCityName());
	};

	Vertex* getNextVertex(){
		return (Vertex*)getBaseOne();
	};

	Base* getEdge(){
		return this-&gt;getBaseTwo();
	};

	Base* getEdge(int i){
		Base* current = this-&gt;getEdge();
		for(int k=0;k&lt;i;k++)
		{
			current = current-&gt;getBaseTwo();
			if(current == PSEUDO)
				return PSEUDO;
		}

		return current;
	};

	string getCityName(){
		return this-&gt;cityname;
	};

	void setCityName(string name){
		this-&gt;cityname = name;
	};

	void addToEdgeList(Base* atel){
		if(this-&gt;getEdge() == PSEUDO)
		{
			this-&gt;setEdgeRoot(atel);
		}
		else
		{
			Base* oldRoot = this-&gt;getEdge();
			this-&gt;setEdgeRoot(atel);
			atel-&gt;setBaseTwo(oldRoot);
		}
	};

	void setVertex(Vertex* vlr){
		this-&gt;setBaseOne(vlr);
	};

	void setEdgeRoot(Base* elr){
		this-&gt;setBaseTwo(elr);
	};
};

#endif
</code></pre>
<p>Naja wie gesagt so wäre es nun teilweise mögliche einfach einen Base* zu übergeben anstatt einen Vertex* bzw. einen Edge*</p>
<p>Kann mir noch jemand weiterhelfen ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/915667</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/915667</guid><dc:creator><![CDATA[Themaximum]]></dc:creator><pubDate>Sat, 12 Nov 2005 07:45:36 GMT</pubDate></item></channel></rss>