0

I am creating a Property Sheet derived from CMFCPropertySheet it is created from the mainframe when a initial editor page is called. My question is when an additional page is called I would like a new tab created for it. Each page that is invoked will be derived by the same class but the max number of pages is unknown so it needs to be defined as

    CEditorPage *m_editorpage[];

but the compiler complains that its using a zero sized array. In the destructor I delete the pages created in a for loop from 0 to number of pages in sheet. in post destroy I delete the this pointer. Program crashes and stops at

    delete this;

If I don't use an array it doesn't crash. But because I am using the same class page in each property page and I don't know how many there will be I need to use a zero sized array. Either way I am getting a memory leak.

How can I create a zero sized CMFCPropertyPage based array in the Property Sheet so I can add additional pages during run time and perform proper cleanup when Property Sheet is closed. I either get a crash or memory leak in every method I have tried.

RobNHood
  • 119
  • 1
  • 2
  • 11

2 Answers2

1

Try to use a dynamic array

CEditorPage *m_editorpage = new CEditorPage[_num_of_editorpage];
....
delete[] m_editorpage ;
2342G456DI8
  • 1,819
  • 3
  • 16
  • 29
0

How about using std::vector class or similar?

o_weisman
  • 804
  • 7
  • 19