Creating a pointer of a struct in C++ -
i have struct defined as
typedef struct bsp_area { struct bsp_area *otherbsparea; /* pointer */ long bspreturncode; short sgroupnum; /* default 0 */ char filler4[6]; /* alignment bytes */ unsigned char bycobolworkarea[20]; /* cobol work area */ // .... , lots of others fields } * pbsp_pass ;
so bsp_area
can hold pointer reference itself, create sort of link list.
in code, have method createnode()
returns bsp_area
method signature bsp_area createnode()
. in method initialize bsp_area
, return it. after calling method, set pointer contains doing this, getting error.
bsp_area cobolpassarea2 = createnode(data1); cobolpassarea->otherbsparea = &cobolpassarea2;
how initialize pointer otherbsp bsp_pass_area
returned createnode()
? please dont advise make createnode return pointer, instead of concrete bsp_area
, requirement.
cobolpassarea->otherbsparea = &cobolpassarea2;
should be
cobolpassarea2.otherbsparea = &cobolpassarea2;
notice ->
has been changed .
, in addition adding 2
variable name, on left side.
Comments
Post a Comment