I was going through one of my local libraries and noticed the follwowing:
class Derived : public Base
{
friend class Base; // serves as a factory
protected:
pthread_spinlock_t allocLock;
bool isSafe{ true };
Derived();
char *funcA() override;
public:
void funcB( bool _in ) override;
virtual ~Derived();
};
I am not able to understand if Base
has been inherited then why it has been made a friend
of Derived
. Also how the comment serves as a factory make sense here?
If it were to access Base
function, ::
operator would have been sufficient.
Is it more related to Design approach?
Aucun commentaire:
Enregistrer un commentaire