vanandel@ncar.ucar.edu (Joe Van Andel) (05/09/91)
Forgive me if this has been discussed recently, but I need to know what (if any) is the syntax for allocating an array of objects, and calling a constructor with arguments for each: If I have a constructor defined with no arguments for the class, I can say: FAST WSmeBSB *eptr = new WSmeBSB[count]; I've tried: FAST WSmeBSB *eptr = new WSmeBSB[count](arg1, arg2); and FAST WSmeBSB *eptr = new WSmeBSB (arg1, arg2)[count]; My compiler won't accept either. I'm using the WWL-1.2 package, and I'm trying to allocate an array of Athena Simple Menu Entries, if you are curious. I'm using g++ version 1.39.0 beta (based on GCC 1.39), on a Sun3, running 4.1.1 A related question, is it safe to allocate space for an array of objects yourself, e.g.: FAST WSmeBSB *eptr = (WSmeBSB *)XtMalloc(sizeof(WSmeBSB) * count); Each of these objects in the dynamic array is later explicitly assigned to. Please email me your responses, and I'll summarize. Joseph VanAndel Internet:vanandel@ncar.ucar.edu NCAR Mail Stop MAR P.O Box 3000 Fax: 303-497-2044 Boulder, CO 80307-3000 Voice: 303-497-2071