<?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[[Erledigt] Finde den Fehler nicht]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich finde den Fehler nicht im Code.<br />
Warum hat Zeile 38 keine Auswirkung auf den Code? Gültigkeitsbereich?<br />
Was müsste geändert werden?</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
#include &lt;iostream&gt;

class B{

private:
	std::vector&lt;double&gt; elements;
public:
	static const int maxdim =3;
	B(){ elements.insert(elements.begin(),maxdim,0.0); }
	double get_dim(int dim) {return elements[dim];}
	void set_dim(int dim,double val) {elements[dim] = val;}
};

class A{
	private:
		std::vector&lt;B&gt; sys;
	public:
		static const int maxsys=3;

		A(){
			B tmpb;
			sys.insert(sys.begin(),maxsys,tmpb);
		}

		B get_sys(int pos) const { return sys[pos];}
		void set_sys(B val) { sys.push_back(val);}
};

int main(void){

	A classa;

	for(int i=0;i&lt;A::maxsys;i++){
		for(int j=0;j&lt;B::maxdim;j++){
				classa.get_sys(i).set_dim(j,1.0);
		}
	}

	for(int i=0;i&lt;A::maxsys;i++){
		std::cout &lt;&lt; &quot;sys=&quot; &lt;&lt; i &lt;&lt; '\n';
		for(int j=0;j&lt;B::maxdim;j++){
			std::cout &lt;&lt; &quot;dim-&quot; &lt;&lt; j &lt;&lt; &quot;=&quot; &lt;&lt; classa.get_sys(i).get_dim(j) &lt;&lt; '\t';
		}
		std::cout &lt;&lt; '\n';
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/269367/erledigt-finde-den-fehler-nicht</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 03:02:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/269367.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 Jun 2010 16:45:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Thu, 24 Jun 2010 09:43:32 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich finde den Fehler nicht im Code.<br />
Warum hat Zeile 38 keine Auswirkung auf den Code? Gültigkeitsbereich?<br />
Was müsste geändert werden?</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
#include &lt;iostream&gt;

class B{

private:
	std::vector&lt;double&gt; elements;
public:
	static const int maxdim =3;
	B(){ elements.insert(elements.begin(),maxdim,0.0); }
	double get_dim(int dim) {return elements[dim];}
	void set_dim(int dim,double val) {elements[dim] = val;}
};

class A{
	private:
		std::vector&lt;B&gt; sys;
	public:
		static const int maxsys=3;

		A(){
			B tmpb;
			sys.insert(sys.begin(),maxsys,tmpb);
		}

		B get_sys(int pos) const { return sys[pos];}
		void set_sys(B val) { sys.push_back(val);}
};

int main(void){

	A classa;

	for(int i=0;i&lt;A::maxsys;i++){
		for(int j=0;j&lt;B::maxdim;j++){
				classa.get_sys(i).set_dim(j,1.0);
		}
	}

	for(int i=0;i&lt;A::maxsys;i++){
		std::cout &lt;&lt; &quot;sys=&quot; &lt;&lt; i &lt;&lt; '\n';
		for(int j=0;j&lt;B::maxdim;j++){
			std::cout &lt;&lt; &quot;dim-&quot; &lt;&lt; j &lt;&lt; &quot;=&quot; &lt;&lt; classa.get_sys(i).get_dim(j) &lt;&lt; '\t';
		}
		std::cout &lt;&lt; '\n';
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1916407</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916407</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Thu, 24 Jun 2010 09:43:32 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 16:51:57 GMT]]></title><description><![CDATA[<p>Weil da von <code>get_sys</code> eine Kopie zurückgegeben wird und du auf diese (temporäre) Kopie eine Änderung machst, welche natürlich keine Auswirkung auf das ursprüngliche Objekt hat.</p>
<p>Zur Lösung des Problems:<br />
Technisch: Gib eine Referenz oder einen Zeiger zurück.<br />
Besser: Ändere das Design. Das verletzt das Konzept der Kapselung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916410</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916410</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Wed, 23 Jun 2010 16:51:57 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 16:56:27 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>Besser: Ändere das Design. Das verletzt das Konzept der Kapselung.</p>
</blockquote>
<p>Wieso? std::string, std::vector,... machen das doch auch so. Sie haben den []-operator überladen und geben eine referenz auf das n-te Element zurück.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916414</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916414</guid><dc:creator><![CDATA[virtual diva]]></dc:creator><pubDate>Wed, 23 Jun 2010 16:56:27 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 16:59:45 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>Zur Lösung des Problems:<br />
Technisch: Gib eine Referenz oder einen Zeiger zurück.</p>
</blockquote>
<p>So? Klappt irgendwie nicht.</p>
<pre><code class="language-cpp">double &amp;set_dim(int dim,double val) {return elements[dim];}
B &amp;set_sys(int pos) {  return sys[pos];}
// Zugriff
classa.set_sys(i).set_dim(j,1.0);
</code></pre>
<p>drakon schrieb:</p>
<blockquote>
<p>Besser: Ändere das Design. Das verletzt das Konzept der Kapselung.</p>
</blockquote>
<p>In wie fern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916416</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 16:59:45 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 17:14:07 GMT]]></title><description><![CDATA[<p>Habe jetzt Referenzen hinzugefügt, klappt leider immer noch nicht</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
#include &lt;iostream&gt;

class B{

private:
	std::vector&lt;double&gt; elements;
public:
	B(){ elements.insert(elements.begin(),3,0.0); }
	const double &amp;get_dim(int dim) const {return elements[dim];}
	double &amp;set_dim(int dim,double val) {return elements[dim];}
};

class A{

private:
	std::vector&lt;B&gt; sys;
public:
	A(){
		B tmpb;
		sys.insert(sys.begin(),3,tmpb);
	}

	const B &amp;get_sys(int pos) const { return sys[pos];}
	B &amp;set_sys(int pos) {  return sys[pos];}
};

int main(void){

	A classa;

	for(int i=0;i&lt;3;i++){
		for(int j=0;j&lt;3;j++){
			classa.set_sys(i).set_dim(j,1.0);
		}
	}

	for(int i=0;i&lt;3;i++){
		std::cout &lt;&lt; &quot;sys=&quot; &lt;&lt; i &lt;&lt; '\n';
		for(int j=0;j&lt;3;j++){
			std::cout &lt;&lt; &quot;dim-&quot; &lt;&lt; j &lt;&lt; &quot;=&quot; &lt;&lt; classa.get_sys(i).get_dim(j) &lt;&lt; '\t';
		}
		std::cout &lt;&lt; '\n' &lt;&lt; '\n';
	}
	std::cout &lt;&lt; '\n';
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1916420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916420</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 17:14:07 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 17:15:29 GMT]]></title><description><![CDATA[<blockquote>
<p>Klappt irgendwie nicht.</p>
</blockquote>
<p>Tolle Fehlerbeschreibung. <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/1916422</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916422</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Wed, 23 Jun 2010 17:15:29 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 17:17:43 GMT]]></title><description><![CDATA[<p>virtual diva schrieb:</p>
<blockquote>
<p>drakon schrieb:</p>
<blockquote>
<p>Besser: Ändere das Design. Das verletzt das Konzept der Kapselung.</p>
</blockquote>
<p>Wieso? std::string, std::vector,... machen das doch auch so. Sie haben den []-operator überladen und geben eine referenz auf das n-te Element zurück.</p>
</blockquote>
<p>Das ist korrekt, aber das sind eher Sonderfälle, weil man da wirklich Zugriff auf die inneren Elemente braucht. Üblicherweise sollte man so etwas allerdings nicht machen.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/22362">@darkfate</a><br />
Was sollen denn die Funktionen deiner meinung nach machen, wenn du eh nur Referenzen auf Objekte zurückgibst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916423</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916423</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Wed, 23 Jun 2010 17:17:43 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 17:21:56 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<blockquote>
<p>Klappt irgendwie nicht.</p>
</blockquote>
<p>Tolle Fehlerbeschreibung. <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>Bezieht sich auf weiter oben, das es keine Auswirkung hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916424</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916424</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 17:21:56 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 17:23:22 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>Was sollen denn die Funktionen deiner meinung nach machen, wenn du eh nur Referenzen auf Objekte zurückgibst?</p>
</blockquote>
<p>Es ist hier stark vereinfacht. Wollte das Grundproblem aufzeigen.<br />
Jetzt gebe ich Referenzen zurück und habe immer noch 0.0 in allen Elementen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916426</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916426</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 17:23:22 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 17:29:28 GMT]]></title><description><![CDATA[<p>Mach ein kurzes, klares Beipspiel, wo der Fehler deiner Meinung nach passiert und beschreib genau, was du für falsch hälst.</p>
<p>Vielleicht hast du mich einfach falsch verstanden, aber die Setter da oben (im letzten Code) sind schlichtweg unsinnig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916429</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Wed, 23 Jun 2010 17:29:28 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 17:43:03 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>Zur Lösung des Problems:<br />
Technisch: Gib eine Referenz oder einen Zeiger zurück.</p>
</blockquote>
<p>An welche Stelle soll da die Referenz hin?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916435</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916435</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 17:43:03 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 17:47:26 GMT]]></title><description><![CDATA[<p>Hat sich erledigt... mussten lediglich zwei Zeilen geändert werden.<br />
Könntest du mir jetzt bitte erklären warum die getter uns setter da unsinning sein sollten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916437</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916437</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 17:47:26 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 17:48:57 GMT]]></title><description><![CDATA[<p>Weil Sie etwas suggerieren, was sie nicht machen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916439</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916439</guid><dc:creator><![CDATA[Zeus]]></dc:creator><pubDate>Wed, 23 Jun 2010 17:48:57 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 17:49:10 GMT]]></title><description><![CDATA[<p>darkfate schrieb:</p>
<blockquote>
<p>Könntest du mir jetzt bitte erklären warum die getter uns setter da unsinning sein sollten?</p>
</blockquote>
<p>Die getter sind nicht das Problem. Und ein setter setzt normalerweise was, oder? Dein setter ist aber nur ein non-const-ref-getter...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916440</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916440</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Wed, 23 Jun 2010 17:49:10 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 18:04:54 GMT]]></title><description><![CDATA[<p>l'abra d'or schrieb:</p>
<blockquote>
<p>darkfate schrieb:</p>
<blockquote>
<p>Könntest du mir jetzt bitte erklären warum die getter uns setter da unsinning sein sollten?</p>
</blockquote>
<p>Die getter sind nicht das Problem. Und ein setter setzt normalerweise was, oder? Dein setter ist aber nur ein non-const-ref-getter...</p>
</blockquote>
<p>Wie macht man es besser?</p>
<p>Ich möchte die Variable nicht public freigeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916446</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916446</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 18:04:54 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 18:26:47 GMT]]></title><description><![CDATA[<p>darkfate schrieb:</p>
<blockquote>
<p>Wie macht man es besser?</p>
</blockquote>
<p>In dem du etwas setzt? Vor allem in B wäre eine Zuweisung nicht schlecht. Wenn du zwar eine &quot;1.0&quot; übergibst, die aber nirgendwo setzt, brauchst du dich nicht wundern, dass du nicht das bekommst was du gesetzt haben wolltest, aber es dann doch nicht getan hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916457</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916457</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Wed, 23 Jun 2010 18:26:47 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 18:33:42 GMT]]></title><description><![CDATA[<p>l'abra d'or schrieb:</p>
<blockquote>
<p>In dem du etwas setzt? Vor allem in B wäre eine Zuweisung nicht schlecht. Wenn du zwar eine &quot;1.0&quot; übergibst, die aber nirgendwo setzt, brauchst du dich nicht wundern, dass du nicht das bekommst was du gesetzt haben wolltest, aber es dann doch nicht getan hast.</p>
</blockquote>
<p>Ich kann gerade nicht nachvollziehen was du meinst, könnten wir mit Codeschnipseln arbeiten? Hier ist das aktuelle, funktionsfähige, Ergebnis.</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
#include &lt;iostream&gt;

class B{

private:
	std::vector&lt;double&gt; elements;
public:
	static const int maxdim =3;
	B(){ elements.insert(elements.begin(),maxdim,0.0); }
	double get_dim(int dim) {return elements[dim];}
	void set_dim(int dim,double val) {elements[dim] = val;}
};

class A{
private:
	std::vector&lt;B&gt; sys;
public:
	static const int maxsys=3;

	A(){
		B tmpb;
		sys.insert(sys.begin(),maxsys,tmpb);
	}

	B get_sys(int pos) const { return sys[pos];}
	B &amp;set_sys(int pos) { return sys[pos];}
	void set_sys(int pos, B val) { sys[pos] = val; }
};

int main(void){

	A classa;

	for(int i=0;i&lt;A::maxsys;i++){
		for(int j=0;j&lt;B::maxdim;j++){
			classa.set_sys(i).set_dim(j,1.0);
		}
	}

	for(int i=0;i&lt;A::maxsys;i++){
		std::cout &lt;&lt; &quot;sys=&quot; &lt;&lt; i &lt;&lt; '\n';
		for(int j=0;j&lt;B::maxdim;j++){
			std::cout &lt;&lt; &quot;dim-&quot; &lt;&lt; j &lt;&lt; &quot;=&quot; &lt;&lt; classa.get_sys(i).get_dim(j) &lt;&lt; '\t';
		}
		std::cout &lt;&lt; '\n';
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1916458</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916458</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 18:33:42 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 18:52:59 GMT]]></title><description><![CDATA[<p>Du hattest vorhin zwischendrin keinen setter, sondern einen weiteren getter implementiert. Warum sollte ein setter überhaupt etwas zurückgeben?</p>
<p>Schau deinen Code einfach nochmal genau an (den zweiten den du gepostet hast).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916460</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916460</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Wed, 23 Jun 2010 18:52:59 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 18:57:54 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>Du hattest vorhin zwischendrin keinen setter, sondern einen weiteren getter implementiert. Warum sollte ein setter überhaupt etwas zurückgeben?</p>
<p>Schau deinen Code einfach nochmal genau an (den zweiten den du gepostet hast).</p>
</blockquote>
<p>Ich weiß gerade nicht wie man es besser/einfacher implementieren könnte.<br />
Bin für jeden Tipp dankbar. Am besten mit einem Stück Code weil ich mir aus den Sätzen sehr schwer tue Code zusammenzubauen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916461</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916461</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 18:57:54 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 19:03:22 GMT]]></title><description><![CDATA[<p>darkfate schrieb:</p>
<blockquote>
<p>drakon schrieb:</p>
<blockquote>
<p>Du hattest vorhin zwischendrin keinen setter, sondern einen weiteren getter implementiert. Warum sollte ein setter überhaupt etwas zurückgeben?</p>
<p>Schau deinen Code einfach nochmal genau an (den zweiten den du gepostet hast).</p>
</blockquote>
<p>Ich weiß gerade nicht wie man es besser/einfacher implementieren könnte.<br />
Bin für jeden Tipp dankbar. Am besten mit einem Stück Code weil ich mir aus den Sätzen sehr schwer tue Code zusammenzubauen.</p>
</blockquote>
<p>Man merkt, dass du ein wenig auf der Leitung stehst.. <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>Du hast es ja bereits richtig gemacht..<br />
Schau nochmal gaaanz genau Zeile 12 im letzten geposteten Code an und vergleich das, was du auf da im zweitletzen geposteten Code hattest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916462</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916462</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Wed, 23 Jun 2010 19:03:22 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 19:10:32 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>Man merkt, dass du ein wenig auf der Leitung stehst.. <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>
</blockquote>
<p>Wird Zeit gleich Feierabend zu machen.<br />
Gibt es generell etwas am Klassen-Design zu verbessern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916465</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 19:10:32 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 19:19:35 GMT]]></title><description><![CDATA[<p>Ohne zu wissen, was die Klassen genau machen sollen ist das eher schwer.<br />
Aber das mit dem zurückgeben von nicht konstanten Referenzen habe ich ja bereits angesprochen.</p>
<p>btw:<br />
Deutschland spielt und du bist am arbeiten? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916469</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Wed, 23 Jun 2010 19:19:35 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 19:21:27 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>btw:<br />
Deutschland spielt und du bist am arbeiten? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /></p>
</blockquote>
<p>Die verlieren eh 3:0<br />
* duck und weg *</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916471</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Wed, 23 Jun 2010 19:21:27 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Wed, 23 Jun 2010 20:00:24 GMT]]></title><description><![CDATA[<p>Es ist so:</p>
<p>Kurz:<br />
Ich habe Koordinaten mit einer bestimmten<br />
Dimension(im Beispiel Dimension=3) in<br />
verschiedenen Koordinatensystemen<br />
(im Beispiel Anzahl der Koordinatensysteme=3).</p>
<p>Diese sollen möglichst bequem abgerufen und gespeichert werden können.</p>
<p>Lang:<br />
Ich habe ein Panoramabild welches auf eine Kugel<br />
projeziert wird und klicke darin mit der Maus.</p>
<p>Bekomme XY Bild-Koordinaten der Maus -&gt; Transformiere sie<br />
in Kugelkoordinaten und speichere sie ab.</p>
<p>Das Zusammengeklickte (Punkte/Knoten/Maschen) soll<br />
eine Topologie darstellen.</p>
<p>Die Klasse Topoobject speichert die gemeinsamen<br />
Eigenschaften wie die Objekte gezeichnet werden sollen.</p>
<p>Coord ist die klassische Koordinate. Sie gehört immer<br />
irgend einem Koordinatensystem an.</p>
<p>Knot ist die Knotenklasse die eine beliebige<br />
Anzahl von Koordinaten speichert.</p>
<p>Zwei Knoten sind eine Ecke usw..</p>
<p>Die ganze Klassenhierarchie sieht so aus:</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
#include &lt;cstdarg&gt;

#include &quot;assert.h&quot;
#include &quot;panoconstants.h&quot;
#include &quot;geotopology.h&quot;

#ifndef TOPOOBJECT_H
#define TOPOOBJECT_H

typedef unsigned int puint;

// Limits
typedef struct{puint max_color,max_size,max_code,max_comment;} topolimits;
topolimits const defaultlimits = {16777216,100,1000,10000};

// Formats
typedef struct{puint HVD,XYZ;} pcoordformats;
pcoordformats const coordformats = {0,1};

// Colors
typedef struct {puint color,size,code;std::string comment;} topoproperty;

class Topoobject{

	private:

		puint color;
		puint size;
		puint code;
		std::string  comment;

	public:

		static const topoproperty propdefault;
		static const topoproperty propcoord;
		static const topoproperty propknot;
		static const topoproperty propedge;
		static const topoproperty propface;

		Topoobject();
		Topoobject(topoproperty new_property);
		Topoobject(puint color, puint size, puint code,const std::string &amp;comment);

		void set_size(puint new_size);
		void set_color(puint new_color);
		void set_code(puint new_code);
		void set_comment(const std::string &amp;new_comment);

		puint get_code() const;
		puint get_size() const;
		puint get_color() const;
		std::string const &amp;get_comment() const;

};

class Coord : public Topoobject{

	private:

		std::vector&lt;double&gt; elements;
		puint format;

	public:
		Coord();
		Coord(puint format, puint maxdim, ... );
		Coord(puint format,puint color,puint size,puint code,const std::string &amp;comment, puint maxdim, ... );

		void set_dim(puint dim, double new_element);
		void set_xyz(double x,double y, double z);
		void set_hvd(double h, double v, double d);
		void set_format(puint new_format) const;

		puint get_format() const;
		double get_dim(puint dim) const;

};

class Knot : public Topoobject{

private:

	std::vector&lt;Coord&gt; coordinatesystem;

public:

	Knot();
	Knot(puint maxsys ... );

	double get_distance(puint sys, Knot &amp;new_knot) const;
	Coord get_sys(puint format) const;
	Coord &amp;set_sys(puint sys);
	void set_sys(Coord new_coord,puint format);

};

class Edge : public Topoobject{

	private:

		puint startknot_id,endknot_id,left_area,right_area;

	public:
		Edge(puint startknot_id, puint endknot_id);
		void set_startknot_id(puint new_startknot_id);
		void set_endknot_id(puint new_endknot_id);

		puint get_startknot_id() const;
		puint get_endknot_id() const;

};

class Face : public Topoobject{ };

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1916483</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916483</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Wed, 23 Jun 2010 20:00:24 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Thu, 24 Jun 2010 07:57:54 GMT]]></title><description><![CDATA[<p>darkfate schrieb:</p>
<blockquote>
<p>l'abra d'or schrieb:</p>
<blockquote>
<p>darkfate schrieb:</p>
<blockquote>
<p>Könntest du mir jetzt bitte erklären warum die getter uns setter da unsinning sein sollten?</p>
</blockquote>
<p>Die getter sind nicht das Problem. Und ein setter setzt normalerweise was, oder? Dein setter ist aber nur ein non-const-ref-getter...</p>
</blockquote>
<p>Wie macht man es besser?</p>
<p>Ich möchte die Variable nicht public freigeben.</p>
</blockquote>
<p>Bin nicht der Profi, aber statt einer Methoden-Verkettung und den direkten Zugriff auf eine Methode von Klasse B, würde ich vorschlagen zusätzliche Methoden<br />
in Klasse A einfügen:</p>
<pre><code class="language-cpp">void set_dimval(int pos,int dim, double val) {sys[pos].set_dim(dim,val);}
double get_dimval(int pos, int dim)const {return sys[pos].get_dim(dim);}

//Nutzung, finde ich intuitiver
classa.set_dimval(i,j,1.0);
classa.get_dimval(i,j);
</code></pre>
<p>Hat aus meiner Sicht auch den Vorteil, dass der Benutzer von A sich nur mit dem Interface von A auseinandersetzen muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916581</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916581</guid><dc:creator><![CDATA[einwurf]]></dc:creator><pubDate>Thu, 24 Jun 2010 07:57:54 GMT</pubDate></item><item><title><![CDATA[Reply to [Erledigt] Finde den Fehler nicht on Thu, 24 Jun 2010 08:16:18 GMT]]></title><description><![CDATA[<p>einwurf schrieb:</p>
<blockquote>
<p>...</p>
</blockquote>
<p>Guter Einwand. Dann hätte ich aber vier statt zwei Funktionen..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1916590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1916590</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Thu, 24 Jun 2010 08:16:18 GMT</pubDate></item></channel></rss>