Method 1: I have two classes using the youyuan class. Because I want to apply each other in the header files of the two classes, the header files of the other class are included in the header files of each class, then, declare another class as a friend class in the definition of this class. As follows: # include "B. H" class CA: Public cdialog
{
Friend class CB; public: CB * m_ B; // note that the pointer type} can be declared in another class as follows: # include "A. H" class CB: Public cdialog
{
Friend class CA;
Public:
Ca * M_a; // note that the final key of pointer type} is to create a new class of the other class in the constructor of each class! Method 2: I have two classes. Because I want to apply each other in the header files of two classes, the header files of the other class are included in the header files of each class, then, declare another class as a friend class in the definition of this class. As follows: # include "B. H" class CA: Public cdialog
{
Friend class CB; public: CB * m_ B; // note that the pointer type} can be declared in another class as follows: Class CA; Class CB: Public cdialog
{
Public:
Ca * M_a; // note that the pointer type must be in CB. the CPP file contains the header file # include "ca. H "the final key is to create a new class for each class in the constructor!