Not sure why I can’t take CDialog and set the memory space in the cpp file. It only works in the header file. Isn’t this the same thing??? thanks
Header file:
public:
CDialog *m_pages[6]; // this works
Header file:
CDialog *m_pages;
cpp file
m_pages = new CDialog[6]; //this fails
After seeing what I did wrong(1st poster: “creating an array of six pointers to CDialog”).
This is what I missed: (and now it works!)
CDialog **m_pages = new CDialog*[6]; //double pointer
Check the documentation. CDialogs require at least one parameter in their constructor, that’s why you can’t allocate them in your second example, since they don’t have a default constructor.
In your first example, you’re creating an array of six pointers to
CDialog. That is completely different from an array of sixCDialog, which is what you are trying to allocate in the second one.