class中访问的问题
定义PolarRe如下#ifndef MATHLIB_H
#define MATHLIB_H
class RandGen {
private:
static bool seed;
public:
RandGen();
virtual double generate() = 0;
};
class PolarRej : public RandGen {
private:
static PolarRej* _instance;
PolarRej(): first(true) {}
bool first;
double rv2;
public:
static PolarRej* Instance();
double generate();
};
class SinCos : public RandGen {
private:
static SinCos* _instance;
SinCos(): first(true) {}
bool first;
double rv2;
public:
static SinCos* Instance();
double generate();
};
class Uniform : public RandGen {
private:
static Uniform* _instance;
Uniform() {}
public:
static Uniform* Instance();
double generate();
};
class Exponential : public RandGen {
private:
static Exponential* _instance;
Exponential() {}
public:
static Exponential* Instance();
double generate();
};
double __stdcall uniform();
double __stdcall exponential();
double __stdcall normalPR();
double __stdcall normalSC();
#endif
但是在double MonteCarlo1Asset::simulate()
{
PolarRej Normal;
return getSpotVal()=getSpotVal()*exp((getIr()-getDiv()-0.5*getVol()*getVol())*getDt()+getVol()*sqrt(getDt())*Normal.generate());
}中 出现 cannot access private member declared in class 'PolarRej',是怎么回事,generate不是public的么?
[ 本帖最后由 zfan85 于 2010-10-15 02:00 编辑 ]