Mail Archives: djgpp/2000/12/26/17:17:20
"Beldraen" <beldraen AT nowhere DOT com> 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:
>
<snip>
> 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
>
- Raw text -