October 10, 2018, 18:37
|
Problem with declaring an object of a certain class
|
#1
|
Member
Join Date: Apr 2016
Posts: 30
Rep Power: 10
|
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
|
|
|