call for void constructors
Posted by Vadim Ogranovich-3 on Oct 25, 2002; 6:18pm
URL: http://quantlib.414.s1.nabble.com/call-for-void-constructors-tp10165.html
Hi,
I find it inconvenient that FdDividendAmericanOption, etc. have no void
constructor. I was working around the problem of zero dividend time and
wanted to overload FdDividendAmericanOption with a new class,
FdDividendAmericanOption2, that will chop off the zero time dividend and
pass only the remaining dividends to FdDividendAmericanOption. Something
like this:
class FdDividendAmericanOption2 : public FdDividendAmericanOption {
public:
// constructor
FdDividendAmericanOption2(Option::Type type, double underlying,
double strike, Spread dividendYield, Rate
riskFreeRate,
Time residualTime, double volatility,
const std::vector<double>& dividends =
std::vector<double>(),
const std::vector<Time>& exdivdates =
std::vector<Time>(),
int timeSteps = 100, int gridPoints = 100);
};
However the problem in actually writing
FdDividendAmericanOption2::FdDividendAmericanOption2 is that I have very
limited "coding space" to check whether I need to chop off the first element
and, if yes, to actually chop it off. Indeed, all these calculations need to
happen before the base class, FdDividendAmericanOption, gets initialized by
its constructor.
I can probably find a workaround (and as I am writing this letter I've come
to realize that I probably don't need it at all), but I thought it might be
interesting to bring this up and get other's opinions about it.
Specifically, I suggest addition of a new function
virtual void FdDividendOption::init(...) that would do what the constructor
now does. The non-void constructor will then call init() to ensure backward
compatability. The difference is that now I can easily implement my staff by
calling init().
IMHO, it is generally good when classes have a void constructor since much
of STL expects them to be available.
Thanks, Vadim
--------------------------------------------------
DISCLAIMER
This e-mail, and any attachments thereto, is intended only for use by the
addressee(s) named herein and may contain legally privileged and/or
confidential information. If you are not the intended recipient of this
e-mail, you are hereby notified that any dissemination, distribution or
copying of this e-mail, and any attachments thereto, is strictly prohibited.
If you have received this e-mail in error, please immediately notify me and
permanently delete the original and any copy of any e-mail and any printout
thereof.
E-mail transmission cannot be guaranteed to be secure or error-free. The
sender therefore does not accept liability for any errors or omissions in
the contents of this message which arise as a result of e-mail transmission.
NOTICE REGARDING PRIVACY AND CONFIDENTIALITY
Knight Trading Group may, at its discretion, monitor and review the content
of all e-mail communications.