Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!milano!cadillac!puma!vaughan From: vaughan@puma.cad.mcc.com (Paul Vaughan) Newsgroups: comp.lang.c++ Subject: use of new Message-ID: <2276@cadillac.CAD.MCC.COM> Date: 16 Aug 89 19:08:18 GMT Sender: news@cadillac.CAD.MCC.COM Lines: 35 Why is a complete class definition required for the use of the new operator? Example: source file trash.cc --------------------- class foo; void bar() { new foo; } --------------------- produces the following error g++ -g -O -fchar-charconst -c -o trash.o trash.cc In function void bar (): trash.cc:4: invalid use of undefined type `struct foo' I have classes that have pointers to their components (class objects) rather than having their components included directly as data members. This allows me to swap out the components with other (derived) versions of the components, either at run or compile time. For instance, I occassionally swap out a silent component for one that prints whenever anything happens to it for debugging purposes. The printing version just redefines some of the virtual functions of the base. Everything works fine, but I wish I didn't have to include the entire class definition in any file that might make a printing version. I don't understand the issues involved here, especially when the new operator can be overloaded. I'm just wondering if anybody thought much about this. Yes, my compile times are getting long enough to make my mind wander onto how to shorten them. Paul Vaughan, MCC CAD Program | ARPA: vaughan@mcc.com | Phone: [512] 338-3639 Box 200195, Austin, TX 78720 | UUCP: ...!cs.utexas.edu!milano!cadillac!vaughan