<?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[Fehler:  expected init-declarator before &#x27;&amp;amp;&#x27; token]]></title><description><![CDATA[<p>Hallo zusammen!</p>
<p>Ich mach gerade nen Programm (bzw. hab damit angefangen) und wollte nun Operatoren überladen.Habe die Klasse matrix definiert und wollte nun mit</p>
<pre><code class="language-cpp">#include &lt;matrix.hpp&gt;

(...)
matrix matrix&amp;::operator = ( const matrix &amp;rhsMatrix )
{for(int i=0;i&lt;this-&gt;numOfColumns;i++)
		{
			for(int j=0;j&lt;this-&gt;numOfRows;j++)
			{
	 		 this-&gt;entry[i][j]=rhsMatrix.entry[i][j];
			}
			return *this
		};
</code></pre>
<p>und in matrix.hpp</p>
<pre><code class="language-cpp">#ifndef MATRIX_HPP
#define MATRIX_HPP

#include &lt;iostream&gt;
#include &lt;vector&gt;

(...)

/** A general class for a matrix with double entries only.
 */
class matrix {

  private:
  /** Those are the actual matrix entries (matrix is a vector of vectors).
   * This is a non-sparse version.
   */
  vector&lt; vector&lt; double &gt; &gt; entry;

  /** The number of rows of the matrix
   */
  int numOfRows;

  /** The number of coloumns of the matrix.
   */
  int numOfColumns;

  public:
  /** Use this to construct a new matrix.
   */
  matrix( const int &amp;numOfRows, const int &amp;numOfColumns );

  /** Return the transposed matrix.
   */
  matrix getTransposed() const;

  /** Dumps matrix to stdout.
   */
  void dump() const;

  /** Retrieve element (i,j).
   */
  double get( const int &amp;i, const int &amp;j ) const;

  /** Set element (i,j) to value.
   */
  void set( const int &amp;i, const int &amp;j, const double &amp;value );

  /** Function that returns the number of rows.
   */
  int getNumOfRows() const;

  /** Function to retrieve the number of columns.
   */
  int getNumOfColumns() const;

  /* some operators */
  /** Assign rhsMatrix to current one.
   */
  matrix&amp; operator = ( const matrix &amp;rhsMatrix );

  /** Add rhsMatrix to current matrix and return NEW matrix.
   */
  matrix operator + ( const matrix &amp;rhsMatrix ) const;

  /** Add rhsMatrix to instance and update it afterwards.
   */
  matrix&amp; operator += ( const matrix &amp;rhsMatrix );

  /** Standard matrix multiplication; result will be stored in new object.
   */
  matrix operator * ( const matrix &amp;rhsMatrix ) const;
};
</code></pre>
<p>Und nun bekomme ich da oben den Fehler...warum?Hab mich schon durchs Internet gesucht,aber iwie gibts da anscheinend mehrere Meinungen zu....keine Ahnung,bin ziemlich verwirrt,wäre super,wenn ihr mir helfen könntet <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>
<p>Edit: expected init-declarator before '&amp;' token<br />
expected <code>,' or</code>;' before '&amp;' token</p>
<p>das ist der Fehler.<br />
Machts gut,<br />
Mirko</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/228699/fehler-expected-init-declarator-before-amp-token</link><generator>RSS for Node</generator><lastBuildDate>Mon, 28 Sep 2026 10:24:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/228699.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 01 Dec 2008 20:24:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler:  expected init-declarator before &#x27;&amp;amp;&#x27; token on Mon, 01 Dec 2008 20:26:07 GMT]]></title><description><![CDATA[<p>Hallo zusammen!</p>
<p>Ich mach gerade nen Programm (bzw. hab damit angefangen) und wollte nun Operatoren überladen.Habe die Klasse matrix definiert und wollte nun mit</p>
<pre><code class="language-cpp">#include &lt;matrix.hpp&gt;

(...)
matrix matrix&amp;::operator = ( const matrix &amp;rhsMatrix )
{for(int i=0;i&lt;this-&gt;numOfColumns;i++)
		{
			for(int j=0;j&lt;this-&gt;numOfRows;j++)
			{
	 		 this-&gt;entry[i][j]=rhsMatrix.entry[i][j];
			}
			return *this
		};
</code></pre>
<p>und in matrix.hpp</p>
<pre><code class="language-cpp">#ifndef MATRIX_HPP
#define MATRIX_HPP

#include &lt;iostream&gt;
#include &lt;vector&gt;

(...)

/** A general class for a matrix with double entries only.
 */
class matrix {

  private:
  /** Those are the actual matrix entries (matrix is a vector of vectors).
   * This is a non-sparse version.
   */
  vector&lt; vector&lt; double &gt; &gt; entry;

  /** The number of rows of the matrix
   */
  int numOfRows;

  /** The number of coloumns of the matrix.
   */
  int numOfColumns;

  public:
  /** Use this to construct a new matrix.
   */
  matrix( const int &amp;numOfRows, const int &amp;numOfColumns );

  /** Return the transposed matrix.
   */
  matrix getTransposed() const;

  /** Dumps matrix to stdout.
   */
  void dump() const;

  /** Retrieve element (i,j).
   */
  double get( const int &amp;i, const int &amp;j ) const;

  /** Set element (i,j) to value.
   */
  void set( const int &amp;i, const int &amp;j, const double &amp;value );

  /** Function that returns the number of rows.
   */
  int getNumOfRows() const;

  /** Function to retrieve the number of columns.
   */
  int getNumOfColumns() const;

  /* some operators */
  /** Assign rhsMatrix to current one.
   */
  matrix&amp; operator = ( const matrix &amp;rhsMatrix );

  /** Add rhsMatrix to current matrix and return NEW matrix.
   */
  matrix operator + ( const matrix &amp;rhsMatrix ) const;

  /** Add rhsMatrix to instance and update it afterwards.
   */
  matrix&amp; operator += ( const matrix &amp;rhsMatrix );

  /** Standard matrix multiplication; result will be stored in new object.
   */
  matrix operator * ( const matrix &amp;rhsMatrix ) const;
};
</code></pre>
<p>Und nun bekomme ich da oben den Fehler...warum?Hab mich schon durchs Internet gesucht,aber iwie gibts da anscheinend mehrere Meinungen zu....keine Ahnung,bin ziemlich verwirrt,wäre super,wenn ihr mir helfen könntet <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>
<p>Edit: expected init-declarator before '&amp;' token<br />
expected <code>,' or</code>;' before '&amp;' token</p>
<p>das ist der Fehler.<br />
Machts gut,<br />
Mirko</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1623968</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1623968</guid><dc:creator><![CDATA[Noah]]></dc:creator><pubDate>Mon, 01 Dec 2008 20:26:07 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler:  expected init-declarator before &#x27;&amp;amp;&#x27; token on Mon, 01 Dec 2008 20:59:42 GMT]]></title><description><![CDATA[<p>Nächstes Mal bitte noch die Zeilennummer des Fehlers (bezogen auf den abgebildeten Code) angeben.</p>
<pre><code class="language-cpp">matrix matrix&amp;::operator =
</code></pre>
<p>Das ist falsch. Das zweite <code>matrix</code> sollte die Klassenzugehörigkeit angeben, das erste ist für den Rückgabewert. Also</p>
<pre><code class="language-cpp">matrix&amp; matrix::operator =
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1623983</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1623983</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Mon, 01 Dec 2008 20:59:42 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler:  expected init-declarator before &#x27;&amp;amp;&#x27; token on Tue, 02 Dec 2008 15:04:24 GMT]]></title><description><![CDATA[<p>Tschuldige,mach ich <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>
<p>Danke,es klappt!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1624408</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1624408</guid><dc:creator><![CDATA[Noah]]></dc:creator><pubDate>Tue, 02 Dec 2008 15:04:24 GMT</pubDate></item></channel></rss>