C++ access to private members
<p>Hi I am reading chapter 4 in Joshi's C++ Design Patterns and Derivatives Pricing and I do not understand some parts of the code. We have a class PayOff and we want to define a class VanillaOption that has PayOff as a member. In order to do this effectively he uses a virtual copy constructor. </p>

<pre><code>#ifndef PAYOFF_H
#define PAYOFF_H

class PayOff
{
private:
public:
    PayOff(){}
    virtual double operator() (double Spot) const = 0;
    virtual PayOff* clone() = 0;
    virtual ~PayOff(){}
};

class PayOffCall : public PayOff
{
private:
    double Strike;
public:
    PayOffCall(double Strike_);
    virtual PayOff* clone(){return new PayOffCall(*this);}
    virtual ~PayOffCall(){}
};
#endif 



#ifndef VO_H
#define VO_H
#include "PayOff.h"

class VanillaOption
{
private:
PayOff* ThePayOffPtr;               
double Expiry;
public:
VanillaOption(PayOff&amp;,double );     //constructor
VanillaOption(VanillaOption&amp; original) {thePayOffPtr = original.thePayOffPtr-&gt;clone(); Expiry = original.Expiry;}       //copy constructor
VanillaOption&amp; operator=(VanillaOption&amp;);       

~VanillaOption();
 };





#endif
</code></pre>

<p>I don't understand how the copy constructor of VanillaOption can access the private members of original i.e. why I can do thePayOffPtr = original.thePayOffPtr->clone(); and Expiry = original.Expiry;. Can anybody help with this? Many thanks in advance.</p>
