I have a general question regarding the throwing syntax of an object. Consider:
#include <stdio.h> struct bad { }; void func() { throw bad; } int main(int, char**) { try { func(); } catch(bad) { printf("Caught\n"); } return 0; }
This code does not compile (g ++ 4.4.3), since the string 'throw' should be replaced by:
throw bad();
Why is this? If I create a bad stack, I create it like this:
bad b; // I can't use 'bad b();' as it is mistaken for a function prototype
I consulted Straustup's book (and this site), but could not find any explanation for what seemed inconsistent to me.
source share