You are here:

C++/an array of pointers


Hi Eddie,

I know that you asked that I stay away from MFC questions, but my program has multiple edit boxes and I would like to make an array of the edit boxes. Since MSVC++ 6 doesn't allow arrays of edit boxes directly, can I make an array of pointers to the edit boxes:
CEdit* pEdit[0] = (CEdit*)GetDlgItem(IDC_EDIT_FIRST)?
I can't seem to make this work, but can you suggest something? How should I initialize an array of pointers?

Thanks in advance for your help,

Hi Neil, thank you for the question.

Sorry for the delay in responding, I had to refresh a little bit on MFC.  I was unable to find documentation about not being able to create an array of edit boxes in VS6.

Do you know how many edit boxes you are going to have in your app so you can allocate an array?

I'd try this:

CEdit* array = new CEdit[numEditsInApp];
array[0] = GetDlgItem(ID);

Sometimes when you try and allocate an array statically it will throw an error about trying to allocate an array of size 0, so you have to use new.

Try something like that and see if it helps.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2017 All rights reserved.

[an error occurred while processing this directive]