How to use global variables

xiaoxiao2021-03-06  111

This is my problem, thank you for Thinkx, Blow_JJ, Maconel, HY1080 solution, now organize the answer.

Use global variables to define variables in .C, in .h extern. In the place where you need to use the variable, it is included. Also pay attention to yourself to add some precompiled translation, you can create a new unit directly, and the pre-compiled will automatically generate.

For example, in Global.cpp and Global.h, define global variables in global.cpp: #include "global.h" // ------------------ INT A; BOOL B; Long C; ANSISTRING D;

Write this in global.h: Extern Int A; Extern Bool B; Extern long C; Extern Ansistring D; in the place where the global variable is used #include "global.h"

转载请注明原文地址:https://www.9cbs.com/read-104013.html

New Post(0)