|
From: Simon I. <s.i...@gm...> - 2008-02-15 09:58:00
|
Hi guys, I'm a little confused about the QuantLib curve classes ForwardCurve, DiscountCurve and ZeroCurve. In the three class definitions we have the member variable mutable Interpolation interpolation_; but in constructing a curve (using the PiecewiseYieldCurve) we use a factory class function (interpolator_.interpolate) to allocate an Interpolation object to the interpolation_ member variable. However, often the object allocated is an object of a derived class e.g. CubicSpline. Now, I know pointers and references can be polymorphic. But in this case a derived class is being allocated to a base class instance... I know most information required for interpolation is contained within the Interpolation::impl_ object but I'm wondering whether: a) my C++ knowledge is lacking and the base class instance (e.g. ForwardCurve::interpolation_) can be polymorphic somehow. Or... b) why a pointer to the derived Interpolation object isn't returned by the factory class (e.g. Cubic::interpolate) - to obviate the need for a polymorphic Interpolation::impl_ member variable? Thanks in advance for enlightening me. Simon |