CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

Expanding a class

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 3, 2005, 04:26
Default Hello, I'm trying to expand
  #1
Member
 
Fabian Peng Karrholm
Join Date: Mar 2009
Posts: 61
Rep Power: 8
fabianpk is on a distinguished road
Hello,
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:

template<class>
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.

/Fabian
fabianpk is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cylindrical combustion chamber expanding mesh Neil FLUENT 0 October 19, 2006 08:34
expanding cylinder surface plots to a plane klarke CFX 3 October 7, 2006 19:43
Expanding Tube BALIK FLUENT 2 October 30, 2003 05:01
Expanding meshes Prashant Main CFD Forum 4 September 6, 2001 06:17


All times are GMT -4. The time now is 06:50.