CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   Expanding a class (

fabianpk October 3, 2005 04:26

Hello, I'm trying to expand
I'm trying to expand the Matrix class to incorporate some standard functions like matrix multiplication. So I want to overload the operator* by including multiplication between two matrices of my new matrix class (which is a subclass to the ordinary Matrix<t> class).

In my superMatrix.H file, I have:
superMatrix<t> operator*(const superMatrix<t>& b);

and then in my .C file:

superMatrix<t> superMatrix<t>::operator*(const superMatrix<t>& b)
{'creating product'}

When I compile, I get this:

superMatrix/superMatrix.C:77: error: redefinition of 'Foam::superMatrix<t> Foam::superMatrix<t>::operator*(const Foam::superMatrix<t>&)'
superMatrix/superMatrix.C:77: error: 'Foam::superMatrix<t> Foam::superMatrix<t>::operator*(const Foam::superMatrix<t>&)' previously declared here

However, if I include the class in a program, I can use the class to correctly compute the matrix product of two matrices. Anyway, If I remove my added definition of matrix product, and still try to multiply two of my new matrices, I get:

testProg.C:58: error: no match for 'operator*' in 'transponatet * reell'
/users/tfd/f98faka/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/complexI.H:266: note: candidates are:

'a long list, the only one including matrices is:'
/users/tfd/f98faka/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/Matrix.C:387: note: Foam::Matrix<t> Foam::operator*(Foam::scalar, const Foam::Matrix<t>&) [with T = Foam::scalar]

So, when I define it, it says I already defined it, but if I don't define it, it says I haven't defined it. I don't have any forward class definitions BTW, or friend things, since I thought I didn't need to define the product as a non-member function.


All times are GMT -4. The time now is 09:44.