I am modifying some C++ code that start with the following code:
class AAAA {
public:
class BBBB : public CCCC { // CCCC from include CCCC.h
friend class AAAA;
typedef ... ;
public:
BBBB() {}
BBBB(AAAA& thething, uint8_t a = 1) {
init(&thething, a);
}
virtual ~BBBB(){}
//...
}
However as non-professional C++ programmer, this is very confusing and daunting.
Why would a subclass have its super class as a friend class?
What is the meaning of:
(a) class BBBB : public CCCC
, and
(b) BBBB() {}
followed by
(c) virtual ~BBBB(){}
, in this case?
I have already looked at the following SO answers: