我有下面的类,它有两个自定义对象作为成员变量。我收到粗体部分的错误。访问组合类的受保护成员的正确方法是什么?我在 f、gleft 和 gright 函数以及尝试调整 u 大小时出现“在此上下文中”错误。
class C
{
protected:
A x;
B y;
double a;
double b;
Eigen::MatrixXd u;
public:
double f(double x)
{
return x;
}
double gleft(double tau)
{
return tau
}
double gright(double tau)
{
return 0;
}
FD_Euro_Put(): x(), y(), a(0), b(0){}
FD_Euro_Put(char y1, double y2, double y3, double y4, double x2,
double x3, double x4, double x5, double x6, double x7):
x(x1, x2, x3, x4, x5, x6, x7)
{
double Xleft = x1*x2;
double Xright = x1*x3;
double Tauf = x1*x1;
double NN = floor((x1/x2);
a = x1*x2 - 0.5;
b = x1*x2 + 0.5;
pde = HeatPDE(y1, NN, Xleft, Xright, Tauf, Alpha); //begin problem area
u.resize(pde.N+1, pde.M+1);
if(fdtype == 'f')
u = pde.Forward_Euler(&f, &gleft, &gright);
else if(fdtype == 'b')
u = pde.Backward_Euler(&f, &gleft, &gright);
else if(fdtype == 'c')
u = pde.Crank_Nicolson(&f, &gleft, &gright); //end problem area
else
cout << "Incorrect choice for finite difference type!" << endl;
}