Vector
Snames [0]="Spring"
Snames [1]="Summer"
Snames [2]="Fall"
Snames [3]="Winter"
Can't figure out how to define it as global static variables, strives for the great god!!!!!
CodePudding user response:
static STD: : vectorSn (4);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
__fastcall TForm20: : TForm20 (TComponent * Owner)
: TForm (the Owner)
{
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void __fastcall TForm20: : FormCreate (TObject * Sender)
{
Sn [0]="Spring";
Sn [1]="Summer";
Sn [2]="Fall";
Sn [3]="Winter";
Caption=sn. The size ();
Caption=sn [1];
Caption=sn. The capacity ();
}
This useful?
CodePudding user response:
First define a global static variables:Vector
Then the initialization:
Void sysInit (void)
{
Snames [0]="Spring";
Snames [1]="Summer";
Snames [2]="Fall".
Snames [3]="Winter".
}
Void sysEnd (void)
{
Snames. The clear ();
}
# pragma startup sysInit//startup: global variable initialization, perform this function,
# pragma exit sysEnd//exit: system perform this function before exit, and then perform a global variable destructor,
C + + realize the initialization section, in this way allows for more than the # pragma startup, but several, execution sequence controlled by the compiler,