No curly braces around main() -- why does this work?

Viewed 2595

I'm working through a book on C++ and in the chapter on errors it has this program (I left a couple of minor things out but it's mostly this):

int main()
try { 
        // our program (<- this comment is literally from the book)
        return 0;
}
catch(exception& e) {
    cerr << "error: " << e.what() << '\n';
    return 1;
}
catch(...) {
    cerr << "Unknown exception\n";
    return 2;
}

This compiled but of course it did nothing so I'm still wondering about

  1. why there isn't a set of curly braces enclosing everything after main()? Are the blocks or shall I call them "catchphrases" (ha!) part of main() or not?
  2. If they are functions how come there's no "int" before catch(whatever)?
  3. If they're not functions, what are they?
  4. re catch(...), I've never seen ellipses used that way. Can I use ellipses anywhere to mean "anything"?
6 Answers
Related