Copy-Constructor

From: Marco Kunze (makunze_at_gmx.de)
Date: 02/28/05


Date: Mon, 28 Feb 2005 12:06:03 +0800

Hi,

I have the following problem:

I am trying to write a small Matrix-class:

class Matrix {
        public:
                Matrix(int r, int c);
                Matrix(Matrix& mat);
                Matrix operator* (Matrix mat);
};

Now, when I do this:

     Matrix m4 = m1;
     m4 = m1 * m1;

everything works fine. But if I try to shorten it to

     Matrix m4 = m1 * m1;

then the compiler says:

Test.cpp: In function `int main(int, char**)':
Test.cpp:61: error: no matching function for call to
`Matrix::Matrix(Matrix)'
Matrix.h:17: error: candidates are: Matrix::Matrix(Matrix&)

It would be great if someone could tell me my mistake, I don't see
anything obvious :(

Thank you.

Marco