Create global variables to save data from different windows in MFC

Source: Internet
Author: User

The format is as follows:

Data_temp.h

Class Cdata_temp
{
Public
Cdata_temp ();
Virtual ~cdata_temp ();
Public
Staticint int_temp;//must be defined as a static type.
static char char_temp;
Staticcstring str_temp;
};

Data_temp. Cpp

#include "stdafx.h"
#include "Data_temp.h"

The initialization of the member function must be done, and it should be in this format, cannot be initialized in the constructor, if there is no initialization, there will be "unresolved errors";
Char cdata_temp::char_temp= ';
CString cdata_temp::str_temp ("");
int cdata_temp::int_temp=0;


Cdata_temp::cdata_temp ()
{

}
Cdata_temp::~cdata_temp ()
{

}

Finally, you only need to #includ "Data-temp" in the header file of the project name. H

Create global variables to save data from different windows in MFC

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.