<?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[&amp;quot;Durch die Konvertierung gehen Qualifizierer verloren&amp;quot;]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe ien Problem mit OO und Pointern.<br />
Folgender Aufruf markiert durch &quot;&lt;---&quot; liefert die Fehlermeldung: &quot;Durch die Konvertierung gehen Qualifizierer verloren&quot;</p>
<pre><code>void test(const robustGeometry::BOEvent &amp; boEv)
{

	 [b]robustGeometry::BOPointType *pType = &amp;boEv.getPointType();&lt;---	hier
	 robustGeometry::BOLine* line = &amp;boEv.getLine();&lt;---	hier[/b]
};

Hier ein Auszug aus dem h File:
class BOLine
	{
	public:
		BOLine(){};		
		BOLine( const double x1, const double y1, 
				const double x2, const double y2, 
				const BOOwnerType owner);
		~BOLine(void){};
		void setX1( const double x );	
		void setX2( const double x );
		void setY1( const double y );
		void setY2( const double y );
		void setOwner( const BOOwnerType owner );

		double getX1( ) const { return x1; };
		double getX2( ) const { return x2; }; 
		double getY1( ) const { return y1; };
		double getY2( ) const { return y2; }; 
		BOOwnerType getOwner( ) const { return owner; }; 

	};

	class BOEvent
	{
	public:
		BOEvent(){};
		BOEvent(const double x, const double y, const BOPointType pType)
		{ 
			setX( x );
			setY( y );
			setPointType( pType );
		};
		BOEvent(const double x, const double y, const BOPointType pType, const BOLine&amp; line)
		{ 
			setX( x );
			setY( y );
			setPointType( pType );
			setLine( line );
		};

		~BOEvent(void){};

		void setX( const double x );	
		void setY( const double y );
		void setPointType( const BOPointType pointType );
		void setLine( const BOLine&amp; line );
		double getX( ) const { return x; };
		double getY( ) const { return y; };		

		[b]BOLine&amp; getLine( ){ return line; };  ---&gt; Hier richtig declariert??[/b]		BOPointType getPointType( ) { return pointType; };
</code></pre>
<p>};</p>
<p>Ist die get Methode schon im h File falsch deklariert?<br />
vielen Dank für eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/301809/quot-durch-die-konvertierung-gehen-qualifizierer-verloren-quot</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 17:29:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/301809.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Apr 2012 09:44:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &amp;quot;Durch die Konvertierung gehen Qualifizierer verloren&amp;quot; on Wed, 04 Apr 2012 09:44:38 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe ien Problem mit OO und Pointern.<br />
Folgender Aufruf markiert durch &quot;&lt;---&quot; liefert die Fehlermeldung: &quot;Durch die Konvertierung gehen Qualifizierer verloren&quot;</p>
<pre><code>void test(const robustGeometry::BOEvent &amp; boEv)
{

	 [b]robustGeometry::BOPointType *pType = &amp;boEv.getPointType();&lt;---	hier
	 robustGeometry::BOLine* line = &amp;boEv.getLine();&lt;---	hier[/b]
};

Hier ein Auszug aus dem h File:
class BOLine
	{
	public:
		BOLine(){};		
		BOLine( const double x1, const double y1, 
				const double x2, const double y2, 
				const BOOwnerType owner);
		~BOLine(void){};
		void setX1( const double x );	
		void setX2( const double x );
		void setY1( const double y );
		void setY2( const double y );
		void setOwner( const BOOwnerType owner );

		double getX1( ) const { return x1; };
		double getX2( ) const { return x2; }; 
		double getY1( ) const { return y1; };
		double getY2( ) const { return y2; }; 
		BOOwnerType getOwner( ) const { return owner; }; 

	};

	class BOEvent
	{
	public:
		BOEvent(){};
		BOEvent(const double x, const double y, const BOPointType pType)
		{ 
			setX( x );
			setY( y );
			setPointType( pType );
		};
		BOEvent(const double x, const double y, const BOPointType pType, const BOLine&amp; line)
		{ 
			setX( x );
			setY( y );
			setPointType( pType );
			setLine( line );
		};

		~BOEvent(void){};

		void setX( const double x );	
		void setY( const double y );
		void setPointType( const BOPointType pointType );
		void setLine( const BOLine&amp; line );
		double getX( ) const { return x; };
		double getY( ) const { return y; };		

		[b]BOLine&amp; getLine( ){ return line; };  ---&gt; Hier richtig declariert??[/b]		BOPointType getPointType( ) { return pointType; };
</code></pre>
<p>};</p>
<p>Ist die get Methode schon im h File falsch deklariert?<br />
vielen Dank für eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2198603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2198603</guid><dc:creator><![CDATA[*lt*---*gt*]]></dc:creator><pubDate>Wed, 04 Apr 2012 09:44:38 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Durch die Konvertierung gehen Qualifizierer verloren&amp;quot; on Wed, 04 Apr 2012 10:38:04 GMT]]></title><description><![CDATA[<p>boEv ist const, die aufgerufenen Funktionen nicht =&gt; const geht &quot;verloren&quot;. Da die Funktionen nur etwas zurück liefern, kannst du sie als const deklarieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2198615</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2198615</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Wed, 04 Apr 2012 10:38:04 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Durch die Konvertierung gehen Qualifizierer verloren&amp;quot; on Wed, 04 Apr 2012 10:43:38 GMT]]></title><description><![CDATA[<p>du hast unten nur non-const-Versionen von getLine und getPointType deklariert, soll heißen, die Methoden garantieren nicht, dass das Objekt, auf denen sie ausgeführt werden, konstant bleibt.</p>
<p>In deiner Funktoin oben rufst du genau diese Methoden aber auf einem Objekt auf, das als konstante (Referenz) deklariert wird. Zusammengenommen machst du mit einer Konstanten etwas, was sie (laut Methodendeklaration) nicht konstant lässt.</p>
<p>Drei Lösungsmöglichkeiten:</p>
<p>a) Die Methoden ändern nichts am Objekt (bei getBoType vermutlich der Fall), die Referenzen, die da zurückgegeben wurden dürfen dann nichts referenzieren, was zum Objekt gehört. Dann sollten die Methoden als const deklariert werden.</p>
<p>b) Die Referenzen verweisen auf Teile des Objekts (bei getLine vermutlich der Fall), dann ist es üblich, jeweils eine const und eine non-const Methode zu schreiben, die jeweils eine const-Referenz bzw. eine non-const-Referenz zurückgeben. Damit kann man auf const-Objekten nur lesend auf die Referenzen zugreifen, bei non-const-Objekten auch schreibend.</p>
<p>c) Die Methoden ändern das Objekt tatsächlich, dann darf test nicht auf einer const-Referenz aufgerufen werden und die Signatur von test muss entsprechend geändert werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2198616</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2198616</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 04 Apr 2012 10:43:38 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Durch die Konvertierung gehen Qualifizierer verloren&amp;quot; on Wed, 04 Apr 2012 11:50:23 GMT]]></title><description><![CDATA[<p>vielen Dank,</p>
<p>ich wollte jetzt alle betrf Methoden const deklarieren.<br />
Wie sieht das dann im c File aus?<br />
getLine ist falsch, s.u. kommt der Fehler &quot;error C2440: 'return': 'const robustGeometry::BOLine' kann nicht in 'robustGeometry::BOLine &amp;' konvertiert werden Durch die Konvertierung gehen Qualifizierer verloren&quot;<br />
Nutze ich KOnstante als Rückgabe von getLine muss diese im Konstruktur initialisiert werden und ich möchte die nicht const Version aber behalten</p>
<pre><code>class BOEvent
	{
	public:
		BOEvent(){};
		BOEvent(const double x, const double y, const BOPointType pType)
		{ 
			setX( x );
			setY( y );
			setPointType( pType );
		};
		BOEvent(const double x, const double y, const BOPointType pType, const BOLine&amp; line)
		{ 
			setX( x );
			setY( y );
			setPointType( pType );
			setLine( line );
		};

		~BOEvent(void){};

		void setX( const double x );	
		void setY( const double y );
		void setPointType( const BOPointType pointType );
		void setLine( const BOLine&amp; line );
		double getX( ) const { return x; };
		double getY( ) const { return y; };		

		BOLine&amp; getLine( ){ return line; };
		BOPointType getPointType( ) { return pointType; };

		BOLine&amp; getLine( ) const { return line; }; &lt;---------
		BOPointType getPointType( )const { return pointType; };

		void Print(ostream&amp; out)const;		

	private :
	  double x;
	  double y;
	  BOPointType pointType;
	  BOLine line;
	  //const BOPointType pointType_const;
	  //const BOLine line_const;
	};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2198642</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2198642</guid><dc:creator><![CDATA[*lt*---*gt*]]></dc:creator><pubDate>Wed, 04 Apr 2012 11:50:23 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Durch die Konvertierung gehen Qualifizierer verloren&amp;quot; on Wed, 04 Apr 2012 14:09:09 GMT]]></title><description><![CDATA[<p>&lt;---&gt; schrieb:</p>
<blockquote>
<p>getLine ist falsch, s.u. kommt der Fehler &quot;error C2440: 'return': 'const robustGeometry::BOLine' kann nicht in 'robustGeometry::BOLine &amp;' konvertiert werden Durch die Konvertierung gehen Qualifizierer verloren&quot;</p>
</blockquote>
<p>Hatte ich geschrieben: Die const-Methode muss eine const-Referenz zurückliefern.</p>
<blockquote>
<p>Nutze ich KOnstante als Rückgabe von getLine muss diese im Konstruktur initialisiert werden</p>
</blockquote>
<p>eine Referenz hat keinen Konstruktor, da ist nichts zu initialisieren.</p>
<blockquote>
<p>und ich möchte die nicht const Version aber behalten</p>
</blockquote>
<p>Hatte ich auch beschrieben - in dem fall musst du beide Versionen anbieten.</p>
<pre><code class="language-cpp">const  BOLine&amp; getLine( ) const { return line; }; 
  BOLine&amp; getLine( ) { return line; };
</code></pre>
<p>Der Compiler sucht sich immer die richtige Methode aus. Natürlich kannst du die Rückgabe von getLine() const auch nur an eine const-Referenz binden, während du die Rückgabe der non-const-Version auch an non-const Referenzen binden darfst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2198704</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2198704</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 04 Apr 2012 14:09:09 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Durch die Konvertierung gehen Qualifizierer verloren&amp;quot; on Wed, 04 Apr 2012 21:12:17 GMT]]></title><description><![CDATA[<p>DAnke, habe es hinbekommen. return Wert von getLine war falsch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2198859</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2198859</guid><dc:creator><![CDATA[*lt*---*gt*]]></dc:creator><pubDate>Wed, 04 Apr 2012 21:12:17 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;Durch die Konvertierung gehen Qualifizierer verloren&amp;quot; on Wed, 04 Apr 2012 21:34:06 GMT]]></title><description><![CDATA[<p>Ach der Return-Wert was schon OK, bloss der Return-Typ war falsch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2198864</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2198864</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Wed, 04 Apr 2012 21:34:06 GMT</pubDate></item></channel></rss>