Nesting of c and c ++ struct and nesting of struct
Nesting of c and c ++ struct
/*************************************** * ******************************* // * Nested struct * C + + **//********************************** * **********************************/struct A {private: int a1 [20]; public: void initialize (); struct B {private: A * B; int * p; public: void initialize (A * ); void next (); int read; void set (int I) ;}; friend A: B ;}; void A: initialize () {memset (a1, 0, sizeof (a1);} void A: B: initialize (A * a) {B = a; p = a-> a1;} void A: B :: set (int I) {* p = I;}/* void main () {A a; A: B b1, b2; int I;. initialize (); b1.initialize (& a); b2.initialize (& a); for (I = 0; I <20; I ++) {b1.set (I ); b2.set (I );}} /*************************************** * ******************************** // * C * nested struct ***//*********************************** * **********************************/typedef struct A {int year; int month; int day ;}; typedef struct B {string name; int age; union {A aa;} xy; struct A aa1 ;}; void main () {B * b1 = NULL; b1-> xy. aa. day = 1991; b1-> aa1.month = 7; getchar ();}
Teach you about the nested structure of C language,
C language cannot achieve your idea. The structure itself has no value, and only the structure members have a value.
Typedef struct {
Float H;
Float L;
Float actual;
} Physic;
Typedef struct {
Physic v;
Physic p;
} Thing;
Thing RTU;
RTU. v. H = 123.456;
RTU. v. L = 0;
RTU. v. actual = 100;
How to place struct in the C language into the function body after nesting
You can add the form of a parameter to the function body for operation. You only need to match the form parameter with the actual parameter type. For example, if a [I]. riqi. year is of the int type, your function can be written as void fun (int I ).