Home > Software engineering >  MFC/C pointer array nesting problems
MFC/C pointer array nesting problems

Time:10-02

I'm in the h file defines the struct
 typedef struct fenlei5 {
Cstrings name;
CStringArray * pinpai;
} fl5;

Typedef struct fenlei {
Cstrings name;
int num;
Fenlei5 * fenlei5 [100];
} fl0;

Fl0 fl.

Then in the CPP file oninit initialization function defined in the
 
Fl. Num=0;
CStringArray a1.
A1. The Add (_T (" ma3 jia3 1 "));
Fl5 fl5a1;
Fl5a1. Name=_T (" ma3 jia3 ");
Fl5a1. Pinpai=& amp; a1;
Fl. Fenlei5 [fl. Num]=& amp; Fl1a1;
Fl. Num++;
//////////////////////////////////////////////////////////when the fl. Fenlei5 [0] - & gt; The name can output is ma3 jia3

But the oninit initialization list in the list after reading this fl. Fenlei5 [0] - & gt; The name will display pointer errors?
How can I solve
Ps: actually I program is fl, fl1, fl2, fl3, fl4 fl5, each is a struct body of fl fenlei1 [100] of fl2 fenlei3 [100] and so on

CodePudding user response:

With CStringArray don't directly using a pointer, if you need 2 d, CStringArray nested

CodePudding user response:

reference 1st floor oyljerry response:
with CStringArray don't directly using a pointer, if you need 2 d, CStringArray Nested

I need a CStringArray + a cstrings preserving classification name so only CStringArray Can't realize!

CodePudding user response:

If use fenlei5 * pointer suggest using new/delete new allocated on the heap, on the stack in beyond the scope will be clean after

Typedef struct fenlei
{
Cstrings name;
int num;
CArray & lt; F15 & gt; Fenlei5;
} f10.

CodePudding user response:

refer to the second floor qq_34464826 response:
Quote: refer to 1st floor oyljerry response:

With CStringArray don't directly using a pointer, if you need 2 d, CStringArray Nested

I need a CStringArray + a cstrings preserving classification name so only CStringArray Can't achieve.

You put the two packaged into one structure
  • Related