In the header file "PayOff1.h"(pasted at the bottom of the message) the PayOff class is created. In the file "PayOff1.cpp," the PayOff function is actually defined.
I understand that "PayOff::PayOff(...)" starts the definition, but why is there a colon after that instead of a parenthesis? I have read most of O'REilly's "Practical C++ Programming," and I cannot seem to find an explanation for what is going on here.
It is an example of a "member initialization list". Look that or just "initializer list" or similar. If you book uses English spelling it will be an "initialisation list".
In the header file "PayOff1.h"(pasted at the bottom of the message) the PayOff class is created. In the file "PayOff1.cpp," the PayOff function is actually defined.
I understand that "PayOff::PayOff(...)" starts the definition, but why is there a colon after that instead of a parenthesis? I have read most of O'REilly's "Practical C++ Programming," and I cannot seem to find an explanation for what is going on here.
PayOff::PayOff(double Strike_, OptionType TheOptionsType_)
:
Strike(Strike_), TheOptionsType(TheOptionsType_)
{
}
double PayOff::operator ()(double spot) const
{
switch (TheOptionsType)
{
case call :
return max(spot-Strike,0.0);
}
// PayOff1.h
ifndef PAYOFF_H
define PAYOFF_H
class PayOff
{
public:
private:
};
endif
It is an example of a "member initialization list". Look that or just "initializer list" or similar. If you book uses English spelling it will be an "initialisation list".
Alternatively it the following links explain it:
http://msdn.microsoft.com/en-us/magazine/cc301399.aspx
http://www.cprogramming.com/tutorial/initialization-lists-c++.html
You can google for many more examples now you know what it is called.
Thanks again. That was very helpful.
... despite the fact that I typed it in something only approximating English. Mutt be tired.