Solutions for the inclusion of Visual C ++ header files

Source: Internet
Author: User

 

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!

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.