<?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[Problem mit get-Methode]]></title><description><![CDATA[<pre><code>int matrix::getVal(int n, int m)
{
	return feld[n][m];
}
</code></pre>
<p>Hi Leute!</p>
<p>Oben hab ich euch meine get-Methode reinkopiert. Mit der will ich in meiner print-Methode auf das zweidimensionale private-Feld zugreifen und in Abhgängigkeit meiner beiden for-Schleifen, den jeweiligen Wert in's cout schicken. Leider kackt mir genau an dieser Stelle das Programm ab!</p>
<p>Was mache ich falsch?</p>
<p>Edit: Das wäre die Klasse dazu:</p>
<pre><code>class matrix
{
private:
	int n, m;
	int** feld;

public:
	matrix(int n, int m);
	~matrix();
	void print(int n, int m);
	void input();
	int getVal(int n, int m);
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/316076/problem-mit-get-methode</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Jul 2026 06:11:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/316076.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 21 Apr 2013 09:01:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 09:03:17 GMT]]></title><description><![CDATA[<pre><code>int matrix::getVal(int n, int m)
{
	return feld[n][m];
}
</code></pre>
<p>Hi Leute!</p>
<p>Oben hab ich euch meine get-Methode reinkopiert. Mit der will ich in meiner print-Methode auf das zweidimensionale private-Feld zugreifen und in Abhgängigkeit meiner beiden for-Schleifen, den jeweiligen Wert in's cout schicken. Leider kackt mir genau an dieser Stelle das Programm ab!</p>
<p>Was mache ich falsch?</p>
<p>Edit: Das wäre die Klasse dazu:</p>
<pre><code>class matrix
{
private:
	int n, m;
	int** feld;

public:
	matrix(int n, int m);
	~matrix();
	void print(int n, int m);
	void input();
	int getVal(int n, int m);
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2317106</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317106</guid><dc:creator><![CDATA[bandchef]]></dc:creator><pubDate>Sun, 21 Apr 2013 09:03:17 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 09:24:05 GMT]]></title><description><![CDATA[<blockquote>
<p>Was mache ich falsch?</p>
</blockquote>
<p>Du gibst keine Informationen über Fehler oder deine <code>print</code> -Funktion. Poste beides.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317109</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317109</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 21 Apr 2013 09:24:05 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 09:25:24 GMT]]></title><description><![CDATA[<p>Das ist die Fehlermeldung: Unbehandelte Ausnahme bei 0x013b16dc in U1A3und4.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0xcccccccc.</p>
<p>Das ist mein Konstruktor:</p>
<pre><code>matrix::matrix(int n, int m) : n(n), m(m)
{
	int** feld = new int*[n];

	//Array allokieren
	for(int i = 0; i &lt; n ; i++)
	{
		feld[i] = new int[m];
	}

	//mit Nullen befüllen
	for(int i = 0; i&lt;n; i++)
	{
		for(int j = 0; j&lt;m; j++)
		{
			feld[i][j] = 0;
		}
	} 
}
</code></pre>
<p>Das ist die print-Methode:</p>
<pre><code>void matrix::print(int n, int m)
{
	//Array ausgeben
	for(int i = 0; i&lt;n; i++)
	{
		for(int j = 0; j&lt;m; j++)
		{
			int temp = getVal(i, j);
			cout &lt;&lt; temp;
		}

		cout &lt;&lt; endl;
	}
}
</code></pre>
<p>Jetzt hab ihr alles wichtige an Code und die Fehlermeldung <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/2317110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317110</guid><dc:creator><![CDATA[bandchef]]></dc:creator><pubDate>Sun, 21 Apr 2013 09:25:24 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 09:32:48 GMT]]></title><description><![CDATA[<p>Da du anscheinend manuelle Speicherverwaltung benutzt, wirst du dabei wohl etwas falsch gemacht haben. Schon alleine die Benutzung roher Zeiger bei offensichtlicher Verletzung der Dreierregel zeigt, dass da schon bei den Grundlagen etwas nicht stimmt. Warum überhaupt manuelle Speicherverwaltung? Nutz doch einen vector! Warum überhaupt eine Liste von Listen? Eine Matrix kannst du leicht auf eine 1D-Struktur mappen, was viel einfacher und effizienter ist!</p>
<p>Vorschlag: Komplett neu machen. Dieses mal mit folgendem Ansatz:</p>
<pre><code>class matrix
{
private:
    size_t size_x, size_y;
    std::vector&lt;int&gt; data;

public:
    matrix(size_t n, size_t m);
//    ~matrix();                Brauchst du nicht mehr
//    void print(int n, int m); Anwendungscode. Nicht Aufgabe der Matrixklasse.
//    void input();             Anwendungscode. Nicht Aufgabe der Matrixklasse.
    int getVal(size_t n, size_t m) const;  // const-correctness beachten!
    int&amp; getVal(size_t n, size_t m);       // Sicherlich auch ganz nützlich, wenn man schreibend zugreifen kann
};
</code></pre>
<p>P.S.: Du hast den Code gepostet, während ich geantwortet habe. Mein Verdacht, dass du mit manueller Speicherverwaltung hantierst und dabei alles falsch machst, bestätigt sich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317112</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317112</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 21 Apr 2013 09:32:48 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 09:35:15 GMT]]></title><description><![CDATA[<p>An die Sache mit den Vektoren hab ich auch schon gedacht. Ich soll aber eigene Felder benutzen!</p>
<p>Von daher kann ich leider mit deinem Tip nicht viel anfangen. Wäre daher nett, wenn du mir sagen könntest, wo der Hase im Pfeffer liegt!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317113</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317113</guid><dc:creator><![CDATA[bandchef]]></dc:creator><pubDate>Sun, 21 Apr 2013 09:35:15 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 09:41:11 GMT]]></title><description><![CDATA[<blockquote>
<pre><code>int operator[]( std::array&lt;int, 2&gt; const&amp; indices ) const;  // const-correctness beachten!
    int&amp; operator[]( std::array&lt;int, 2&gt; const&amp; indices )       // Sicherlich auch ganz nützlich, wenn man schreibend zugreifen kann
</code></pre>
</blockquote>
<p>FTFY <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="😃"
    /><br />
(Mit init-list benutzen, ginge aber natürlich auch mit dem Funktionsoperator)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317114</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317114</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 21 Apr 2013 09:41:11 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 09:46:44 GMT]]></title><description><![CDATA[<p>Habt ihr denn nicht gelernt wie das geht, wenn ihr das selber machen sollt? Die Regel der großen Drei wurde schon genannt. Wahrscheinlich ist noch viel mehr falsch, weil man vieles falsch machen kann und du nicht alles gezeigt hast. Aber wir können dir hier nicht alles beibringen, worauf es ankommt. Im Prinzip ist deine erste Aufgabe, std::vector nachzuprogrammieren. Dazu brauchst du mindestens schon einmal folgende Stichworte:<br />
<a href="http://en.wikipedia.org/wiki/Rule_of_three_%28C%2B%2B_programming%29" rel="nofollow">http://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming)</a><br />
<a href="http://en.wikipedia.org/wiki/RAII" rel="nofollow">http://en.wikipedia.org/wiki/RAII</a></p>
<p>Wenn das fertig und getestet(!) ist, dann bastelst du damit deine Matrixklasse. Und zwar wirklich nur 1D! Das 2D zu machen ist (fast immer<sup>*</sup>) Unsinn.</p>
<p><sup>*</sup>: Diese Relativierung bezieht sich nicht auf die hier vorliegende Aufgabe. Naturwissenschaftler mögen keine absoluten Aussagen, wenn sie nicht in <strong>jedem</strong> Fall stimmen. Die Relativierung ist für die Klugscheißer im Forum gedacht, die ansonsten einen Flamewar starten würden, dass sie einen Sonderfall kennen, in dem das sinnvoll ist. Daher nochmal absolute Aussage: Solch ein Fall liegt hier nicht vor. 1D ist angesagt.</p>
<p>Sone schrieb:</p>
<blockquote>
<blockquote>
<pre><code>int operator[]( std::array&lt;int, 2&gt; const&amp; indices ) const;  // const-correctness beachten!
    int&amp; operator[]( std::array&lt;int, 2&gt; const&amp; indices )       // Sicherlich auch ganz nützlich, wenn man schreibend zugreifen kann
</code></pre>
</blockquote>
<p>FTFY <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="😃"
    /><br />
(Mit init-list benutzen, ginge aber natürlich auch mit dem Funktionsoperator)</p>
</blockquote>
<p>Wo soll denn da der Vorteil sein, außer, dass es umständlicher<sup>+</sup> ist?</p>
<p><sup>+</sup>: Ich bin nicht mehr sicher, ob das in C++ als Vorteil oder als Nachteil gilt <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/2317115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317115</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 21 Apr 2013 09:46:44 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 09:48:02 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Sone schrieb:</p>
<blockquote>
<blockquote>
<pre><code>int operator[]( std::array&lt;int, 2&gt; const&amp; indices ) const;  // const-correctness beachten!
    int&amp; operator[]( std::array&lt;int, 2&gt; const&amp; indices )       // Sicherlich auch ganz nützlich, wenn man schreibend zugreifen kann
</code></pre>
</blockquote>
<p>FTFY <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="😃"
    /><br />
(Mit init-list benutzen, ginge aber natürlich auch mit dem Funktionsoperator)</p>
</blockquote>
<p>Wo soll denn da der Vorteil sein, außer dass es umständlicher ist?</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /></p>
<p>Naja, und außerdem passt es besser. Wenn du eine Matrix auslesen willst, dann nimmst du halt den <code>operator[]</code> .</p>
<p>Siehe auch Boost, AFAIR mit <code>boost::range</code> machen die das da....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317116</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 21 Apr 2013 09:48:02 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 09:49:20 GMT]]></title><description><![CDATA[<p>Übrigens: Wie intuitiv ist schon</p>
<pre><code>a.get(1, 2) = 8;
</code></pre>
<p>Viel lieber:</p>
<pre><code>a[{1, 2}] = 8;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2317118</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317118</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 21 Apr 2013 09:49:20 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 10:04:55 GMT]]></title><description><![CDATA[<p>So Leute, ich probier's nochmal. Ich würde sehr gerne an meinem Code weiterarbeiten. Vielleicht könnt ihr mich ja auf so manchen Fehler hinweisen? Ich kopier jetzt mal allen Code rein:</p>
<pre><code>#include&lt;iostream&gt;
#include&quot;U1A3und4header.h&quot;
using namespace std;

int main()
{
	matrix matrixLinks(4,4);
	matrix matrixRechts(4,4);

return 0;
}
</code></pre>
<pre><code>#ifndef U1A3UND4HEADER__H
#define U1A3UND4HEADER__H

class matrix
{
private:
	int n, m;
	int** feld;

public:
	matrix(int n, int m);
	~matrix();
	void print(int n, int m);
	void input();
	int getVal();
};

#endif
</code></pre>
<pre><code>#include&lt;iostream&gt;
#include&quot;U1A3und4header.h&quot;
using namespace std;

matrix::matrix(int n, int m) : n(n), m(m)
{
	int** feld = new int*[n] ();

	//Array allokieren
	for(int i = 0; i&lt;n ; i++)
	{
		feld[i] = new int[m] ();
	}
}

matrix::~matrix()
{
	for (int j=0; j&lt;n ; j++)
	{
        delete[] feld[j];
	}

	delete[] feld;
}
</code></pre>
<p>Die &quot;getVal&quot;-Methode hab ich nun nochmal gelöscht. Mir fällt nämlich jetzt schon auf, dass der Destruktor den gleichen Fehler wie die getVal-Methode bringt.</p>
<p>Ich denke ein Fehler liegt dann wohl schon am Anfang beim allokieren...</p>
<p>Helft ihr mir?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317119</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317119</guid><dc:creator><![CDATA[bandchef]]></dc:creator><pubDate>Sun, 21 Apr 2013 10:04:55 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 10:08:15 GMT]]></title><description><![CDATA[<p>bandchef: Du initialisierst in deinem Konstruktor eine lokale Variable feld und nicht die gleichnamige Membervariable. Dadurch erzeugst du einerseits ein Speicherloch, da der allozierte Speicher niemals freigegeben wird, und andererseits bleibt die Membervariable feld uninitialisiert, so dass es beim Zugriff darauf zu undefiniertem Verhalten kommt.</p>
<p>Was SeppJ sagt, gilt natürlich trotzdem, das ist aber anscheinend nicht die direkte Ursache für dein Problem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317120</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317120</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Sun, 21 Apr 2013 10:08:15 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 10:45:29 GMT]]></title><description><![CDATA[<p>NATÜRLICH!</p>
<p>Jetzt fällts mir auch auf! Nur wie kann ich auf das Feld in der Klasse zugreifen?</p>
<p>Edit: So richtig?</p>
<pre><code>matrix::matrix(int n, int m) : n(n), m(m)
{
	this-&gt;feld = new int*[n] ();

	//Array allokieren
	for(int i = 0; i&lt;n ; i++)
	{
		this-&gt;feld[i] = new int[m] ();
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2317127</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317127</guid><dc:creator><![CDATA[bandchef]]></dc:creator><pubDate>Sun, 21 Apr 2013 10:45:29 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Thu, 12 Jun 2014 02:30:19 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317129</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317129</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 12 Jun 2014 02:30:19 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 11:28:52 GMT]]></title><description><![CDATA[<p>Ich will hier nun eine Methode Coden für eine Matrixmultikplikation. Ich hab auch schon wieder Code dafür:</p>
<pre><code>void matrix::mul(matrix feldLinks, matrix feldRechts)
{
	for (int i=0; i&lt;this-&gt;m; m++)	//Zeilen durchschalten
	{
		for (int j=0; j &lt; this-&gt;n; j++)		//Spalten durchschalten
		{
			for (int inner = 0; inner&lt;this-&gt;n; inner++)		//Multiplizieren
			{
				this-&gt;feld[i][j] = this-&gt;feld[i][j] + (feldLinks.getVal(i, inner) * feldRechts.getVal(i, j));
			}
		}

		cout &lt;&lt; endl;
	}
}
</code></pre>
<p>Die Klasse sieht nun mittlerweile so aus:</p>
<pre><code>class matrix
{
private:
	int n, m;
	int** feld;

public:
	matrix(int m, int n);
	~matrix();
	void print();
	void input();
	void mul(matrix feldLinks, matrix feldRechts);
	int getVal(int m, int n);
	void setVal(int m, int n, int val);
};
</code></pre>
<p>Die main Aufrufe hab ich so gemacht:</p>
<pre><code>matrix matrixLinks(3,3), matrixRechts(3,3), matrixErgebnis(3,3);

	matrixLinks.input();
	matrixRechts.input();
	matrixErgebnis.print();

	matrixErgebnis.mul(matrixLinks, matrixRechts);
	matrixErgebnis.print();
</code></pre>
<p>Problem daran ist nun, dass nach dem Aufruf der vorletzten Zeile in der main das Programm augenblicklich ohne Warnung stehen bleibt. Der Compiler kompiliert fehlerfrei! Was könnte das sein? Riecht irgendwie nach Endlosschleife...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317135</guid><dc:creator><![CDATA[bandchef]]></dc:creator><pubDate>Sun, 21 Apr 2013 11:28:52 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 11:35:10 GMT]]></title><description><![CDATA[<p>ich würde zunächst mal die Membervariablen umbenennen, damit sie anders heißen, als die gleichnamigen Funktionesparameter</p>
<pre><code>int n, m;
</code></pre>
<p>wenn der Compiler da keinen Drehwurm bekommt, bekommt ihn der menschliche Leser</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317136</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317136</guid><dc:creator><![CDATA[dd++ 0]]></dc:creator><pubDate>Sun, 21 Apr 2013 11:35:10 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 11:36:48 GMT]]></title><description><![CDATA[<blockquote>
<p>wenn der Compiler da keinen Drehwurm bekommt</p>
</blockquote>
<p>Ne, der bekommt gar nix.</p>
<blockquote>
<p>ich würde zunächst mal die Membervariablen umbenennen, damit sie anders heißen, als die gleichnamigen Funktionesparameter</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /><br />
Wohl eher andersrum!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317137</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317137</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 21 Apr 2013 11:36:48 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 11:48:52 GMT]]></title><description><![CDATA[<p>um herauszufinden, ob der Compiler da einen Drehwurm bekommt, siehe ISO/IEC 14882:2011 3.4 Name lookup S. 45-59 (sind nur ca. 14 Seiten zu durchforsten <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>
]]></description><link>https://www.c-plusplus.net/forum/post/2317140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317140</guid><dc:creator><![CDATA[dd++ 0]]></dc:creator><pubDate>Sun, 21 Apr 2013 11:48:52 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Thu, 12 Jun 2014 02:30:26 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317194</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 12 Jun 2014 02:30:26 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 15:44:34 GMT]]></title><description><![CDATA[<p>bandchef schrieb:</p>
<blockquote>
<pre><code>void matrix::mul(matrix feldLinks, matrix feldRechts)
{
  for (int i=0; i&lt;this-&gt;m; m++)	//Zeilen durchschalten
  ...
}
</code></pre>
</blockquote>
<p>m++?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317210</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Sun, 21 Apr 2013 15:44:34 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 16:15:22 GMT]]></title><description><![CDATA[<p>Swordfish schrieb:</p>
<blockquote>
<p>Wovon soll da <em>irgendwer</em> 'nen Drehwurm bekommen?!</p>
</blockquote>
<p>in diesem Konstruktor</p>
<pre><code>matrix::matrix(int n, int m) : n(n), m(m)
</code></pre>
<p>gelten folgende Regeln:</p>
<blockquote>
<p>3.4.1 Unqualified name lookup<br />
11 During the lookup for a name used as a default argument (8.3.6) in a function parameter-declaration-clause or used in the expression of a mem-initializer for a constructor (12.6.2), the function parameter names are visible and hide the names of entities declared in the block, class or namespace scopes containing the function declaration. [ Note: 8.3.6 further describes the restrictions on the use of names in default arguments. 12.6.2 further describes the restrictions on the use of names in a ctor-initializer. —end note ]<br />
12.6.2 Initializing bases and members<br />
2 In a mem-initializer-id an initial unqualified identifier is looked up in the scope of the constructor’s class and, if not found in that scope, it is looked up in the scope containing the constructor’s definition. [ Note: If the constructor’s class contains a member with the same name as a direct or virtual base class of the class, a mem-initializer-id naming the member or base class and composed of a single identifier refers to the class member. A mem-initializer-id for the hidden base class may be specified using a qualified name. —end note ] Unless the mem-initializer-id names the constructor’s class, a non-static data member of the constructor’s class, or a direct or virtual base of that class, the mem-initializer is ill-formed.<br />
12 Names in the expression-list or braced-init-list of a mem-initializer are evaluated in the scope of the constructor for which the mem-initializer is specified. [ Example:<br />
class X {<br />
int a;<br />
int b;<br />
int i;<br />
int j;<br />
public:<br />
const int&amp; r;<br />
X(int i): r(a), b(i), i(i), j(this-&gt;i) { }<br />
};<br />
initializes X::r to refer to X::a, initializes X::b with the value of the constructor parameter i, initializes X::i with the value of the constructor parameter i, and initializes X::j with the value of X::i; this takes place each time an object of class X is created. —end example ] [ Note: Because the mem-initializer are evaluated in the scope of the constructor, the this pointer can be used in the expression-list of a mem-initializer to refer to the object being initialized. —end note ]</p>
</blockquote>
<p>in der mem-initializer-list im Konstrukor kann der Compiler also n und n noch auseinanderhalten, aber spätestens hier ist dann der Wurm drin:</p>
<pre><code>void print(int n, int m);
</code></pre>
<p>der Compiler führt das dann zwar aus, aber es ist besser, die Member n und m anders zu benennen als die Funktionsparameter, denn in der Funktion print sind die Member n und m hidden und es geschehen merkwürdige Dinge</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317220</guid><dc:creator><![CDATA[dd++ 0]]></dc:creator><pubDate>Sun, 21 Apr 2013 16:15:22 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Thu, 12 Jun 2014 02:30:22 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317226</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 12 Jun 2014 02:30:22 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 16:51:21 GMT]]></title><description><![CDATA[<p>Noch einmal: Da ist für den Compiler alles völlig klar.</p>
<p>Und auch für den C++-Programmierer: Denn die Faustregel ist: Zuerst werden in inneren, und dann in äußeren Scopes gesucht. Und in der Initialisierungsliste lässt sich anhand der Syntax und logischen Gegebenheiten (wie der, dass Funktionsparameter nicht in der Initialisierungsliste &quot;initialisiert&quot; werden können) eben die jeweiligen Namen deduzieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317230</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317230</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 21 Apr 2013 16:51:21 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 16:54:20 GMT]]></title><description><![CDATA[<p>ihr würded also empfehlen, die Benennung der Member und Funktionsparameter beizubehalten?</p>
<pre><code>class matrix
{
private:
    int n, m;
    int** feld;

public:
    matrix(int n, int m);
    ~matrix();
    void print(int n, int m);
    void input();
    int getVal(int n, int m);
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2317232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317232</guid><dc:creator><![CDATA[dd++ 0]]></dc:creator><pubDate>Sun, 21 Apr 2013 16:54:20 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 16:57:45 GMT]]></title><description><![CDATA[<blockquote>
<p>ihr würded also empfehlen, die Benennung der Member und Funktionsparameter beizubehalten?</p>
</blockquote>
<p>Wir haben gar nix empfohlen und auch nichts suggeriert. Ich würde beispielsweise, tatsächlich um ein schnelleres Verstehen des Codes zu fördern, die Funktionsparameter mit Unterstrichen o.ä. entsprechend Kennzeichnen. Wichtig ist, dass man diesen Stil dann konsequent beibehält.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317233</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317233</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 21 Apr 2013 16:57:45 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 17:08:08 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>Ich würde beispielsweise, tatsächlich um ein schnelleres Verstehen des Codes zu fördern, die Funktionsparameter mit Unterstrichen o.ä. entsprechend Kennzeichnen. Wichtig ist, dass man diesen Stil dann konsequent beibehält.</p>
</blockquote>
<p>Bitte nicht schon wieder diese Diskussion!<br />
Ich würde generell nicht n und m verwenden, sondern irgendetwas wie width, height oder rows, columns oder so.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317238</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317238</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sun, 21 Apr 2013 17:08:08 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit get-Methode on Sun, 21 Apr 2013 17:34:24 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>Sone schrieb:</p>
<blockquote>
<p>Ich würde beispielsweise, tatsächlich um ein schnelleres Verstehen des Codes zu fördern, die Funktionsparameter mit Unterstrichen o.ä. entsprechend Kennzeichnen. Wichtig ist, dass man diesen Stil dann konsequent beibehält.</p>
</blockquote>
<p>Bitte nicht schon wieder diese Diskussion!<br />
Ich würde generell nicht n und m verwenden, sondern irgendetwas wie width, height oder rows, columns oder so.</p>
</blockquote>
<p>Aha, du hast keine Lust auf die Diskussion, förderst sie aber durch deine Anteilnahme...</p>
<p>Persönlich könnte ich die Variablen leichter ihrem Zweck zuordnen, wenn ich sie auf die Membervariablen &quot;abbilden&quot; kann, aber das ist Geschmackssache.<br />
(Dementsprechend würde ich auch den Member zu <code>mWidth</code> &amp; co. o.ä. umbenennen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2317251</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2317251</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 21 Apr 2013 17:34:24 GMT</pubDate></item></channel></rss>