Home > Back-end >  C builder how to two form Shared variables, including structure variables
C builder how to two form Shared variables, including structure variables

Time:09-28

A structure position, for example, how the FORM1 and FORM2 share, modify the data?
Struct position {
int x;
Int y;
Float p;
};

Position the position [17] [41] [20].

CodePudding user response:

Contains the other side of the header file should be ok,

CodePudding user response:

No, I also defines the variables and the structure
For example,
Struct position {
int x;
int y;
Float p;
};
Position the position [17] [41] [20].
Int ABC;
Modify the ABC in FORM2 form, see in the FORM1

CodePudding user response:

Modify the ABC in FORM2 form, in FORM1
See ABC has changed, but modify the position [0] [0] [0], z
Do not change,

CodePudding user response:

The
reference 3 floor wrw001 response:
modify the ABC in FORM2 form, in FORM1
See ABC has changed, but modify the position [0] [0] [0], z
Do not change,


The code posted a look

CodePudding user response:

Put the following code in a. H file, contain the two window. H file
Struct position {
int x;
int y;
Float p;
};

Extern position position [17] [41] [20].//declare external variable
One of the window, define the position again position [17] [41] [20].
In this way, the position [17] [41] [20]. In the project is global

CodePudding user response:

5 floor can be

CodePudding user response:

Reference:
[] beginners c + + Builder is one of the most simple multiple file form the application example of
http://download.csdn.net/detail/u010165006/8992607

CodePudding user response:

1. Define a global variable
2. A class is defined as the public, another class to access the class - & gt; XXXX

CodePudding user response:

Two form Shared variables, containing each other header files, and then in their respective variables declared in a header file, defined in the CPP files can,
For example: Unit1 structure of A variable is A need to share, Unit2 of the variable structure B B need to share, so:
Unit1. H file
 struct A 
{
.
};
Extern A, A.

Unit1. CPP file
 A, A. 

Unit2. H file

 struct B{
.
};
Extern B B;

Unit2. CPP file
 B B; 

And then in Unit1 and Unit2 can use a and b,

CodePudding user response:

I tend to be
Use in Form2 Form1 - & gt; A,
Use in Form1 Form2 - & gt; B,
Such use ok?
  • Related