Topic: Question about using 'new' and 'delete


Author: atrasi@cs.umr.edu (Atul Trasi)
Date: Thu, 8 Apr 1993 18:37:27 GMT
Raw View
Hi netters,

I was wondering if you could help me with a problem I have.

I am having an array of pointers to a class derived from another class as
shown below.

class UIW_ICON { ... }

class MIXER_ICON : public UIW_ICON { ... }

MIXER_ICON *mixerIcon[5];

The objects of type MIXER_ICON are created using 'new' as follows

mixerIcon[0] = new MIXER_ICON(...);

This is being done in a function and 'mixerIcon' is a global variable.

I am using the 'delete' operator within main() to delete the space allocated
for 'mixerIcon'.  I don't know what I am doing wrong in this but my program
just hangs after I exit the program using the menu I have created.  This
happens only when there is an icon on the screen.

The 'delete' is done as follows:

for (int i=0;i<5;i++)
 delete mixerIcon[i];

All this is for a graphical package for Process Data Reconciliation.  I am
using Turbo C++ and Zinc Interface Library.

I would appreciate your response.

Atul Trasi
University of Missouri - Rolla
trasi@ee.umr.edu