CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Problem with declaring an object of a certain class (https://www.cfd-online.com/Forums/openfoam-solving/208155-problem-declaring-object-certain-class.html)

shanvach October 10, 2018 18:37

Problem with declaring an object of a certain class
 
Hi all,

This is a pretty basic but I need some help. I want to access a member function called GaussNormal() inside the Random class. So I first created a object rnd of class Random.Then called the member function. The following is what I wrote

Code:

Random& rnd;
scalar rn = rnd.GaussNormal();

and I get the following error
Code:

In file included from twoPhaseEulerFoam.C:107:0:
pU/UEqns.H: In function ‘int main(int, char**)’:
pU/UEqns.H:27:13: error: ‘rnd’ declared as reference but not initialized
    Random& rnd;
            ^
pU/UEqns.H:28:33: error: no matching function for call to ‘Foam::Random::GaussNormal()’
    scalar rn = rnd.GaussNormal();

I think I might have to use a constructor, but I don't know how to work that out.
Your help in this matter is greatly appreciated.

Thanks and Regards,
Shantanu Vachhani


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