|
[Sponsors] |
November 3, 2014, 11:37 |
expected primary-expression before .....
|
#1 |
Senior Member
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17 |
Hi guys,
I added this piece of code into the original one: Code:
Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff() const { return drag_->K(); } Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff(const volScalarField& M30, const volScalarField& M20) const { return drag_->K(const volScalarField& M30, const volScalarField& M20); } Code:
twoPhaseSystem.C: In member function ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::twoPhaseSystem::dragCoeff(const volScalarField&, const volScalarField&) const’: twoPhaseSystem.C:291:21: error: expected primary-expression before ‘const’ return drag_->K(const volScalarField& M30, const volScalarField& M20); ^ twoPhaseSystem.C:291:48: error: expected primary-expression before ‘const’ return drag_->K(const volScalarField& M30, const volScalarField& M20); ^ twoPhaseSystem.C:292:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ make: *** [Make/linux64GccDPOpt/twoPhaseSystem.o] Error 1 Code:
Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff() const { return drag_->K(); } Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff(const volScalarField& M30, const volScalarField& M20) const { return drag_->K(int A); } But this is totally fine: Code:
Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff() const { return drag_->K(); } Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff(const volScalarField& M30, const volScalarField& M20) const { return drag_->K(); } Code:
return drag_->K(const volScalarField& M30, const volScalarField& M20); or return drag_->K(int A); Thanks |
|
November 4, 2014, 04:11 |
|
#2 | ||
Senior Member
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20 |
Quote:
You need to distinguish parameter passing and receiving. When you receive a parameter in a function (blue, below), you must specify its type. You are already doing this. When you pass a variable to another function (purple, below), you must solely pass the variable, without including its type in front: the compiler already knows its type. If you do put its type in front, you are declaring a new variable, which you do not initialize. That will result in a compilation error. Quote:
Code:
Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff(const volScalarField& M30, const volScalarField& M20) const { return drag_->K(M30, M20); } |
|||
November 4, 2014, 04:23 |
|
#3 |
Senior Member
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17 |
Exactly! Thank you very much!!!!!!!!!
bro!! |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to install CGNS under windows xp? | lzgwhy | Main CFD Forum | 1 | January 11, 2011 19:44 |
CGNS lib and Fortran compiler | manaliac | Main CFD Forum | 2 | November 29, 2010 07:25 |
POSDAT problem | piotka | STAR-CD | 4 | June 12, 2009 09:43 |
wmake compiling Problem with OF1.5 | openTom | OpenFOAM Installation | 4 | May 3, 2009 15:44 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |