From: "Marp" Newsgroups: comp.os.msdos.djgpp Subject: Re: Throwing a class yeilds a linker error. Date: Tue, 26 Dec 2000 16:13:44 -0500 Organization: MindSpring Enterprises Lines: 42 Message-ID: <92b1jr$c2u$1@slb7.atl.mindspring.net> References: <3a4a05d9 DOT 101250781 AT news DOT clmba1 DOT mo DOT home DOT com> NNTP-Posting-Host: 04.30.99.87 X-Server-Date: 26 Dec 2000 21:12:27 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Beldraen" wrote in message news:3a4a05d9 DOT 101250781 AT news DOT clmba1 DOT mo DOT home DOT com... > I'm trying to learn how to throw classes, but something weird is going > on. Here's the code, which is right out of a book I am reading: > > void main(void) > { > B b(); You should not use parentheses when you don't pass any arguements to the constructor when instantiating an object. If you do, it requires you to define a constructor, which is why you get the "undefined reference" from the linker. If you remove the parentheses, the linker error goes away and your program does what you expect it to do (I verified this). Hope this helps. Marp > try > { > throw b; > } > catch(B c) > { > cout << "Caught!" << endl; > } > } > > Compiling works just fine. But, ld returns an error: > undefined reference to 'b(void)' > > I've not been able to figure out if DJGPP can't throw classes or what. > > Thanks for you help, > Chad >