C++ Exceptions

posted in Ubik
Published October 21, 2005
Advertisement
I've decided to actually learn how to use exceptions in C++. I'm a bit embarrassed to admit that i've never used them - but i've been able to live without them and just haven't gotten around to looking into it yet. I suppose that's one of the downsides of being largely self taught - lots of gaps in your programming knowledge.

Next up i'd like to get more comfortable with templates, dig deeper into the standard library, look at something like CVS or subversion, evaluate doxygen, and spend some more time with boost... That and maybe get out of the design phase and actually get some work done on a game.
Previous Entry .
Next Entry Update
0 likes 1 comments

Comments

Oluseyi
Exceptions are interesting, but difficult to use properly due to C++'s complex type system. Taking your exception objects by reference ameliorates issues with copies of the exception object being made. Take a look at the C++ Exception Class Hierarchy: you should generally derive your own exception types from std::logic_error or std::runtime_error.

To really get a feel for exceptions, though, you need to step away from C++ for a while and program in languages where they are first class constructs. Java has a far more pervasive use of exceptions, as well as listeners. Java, Python, Windows Structured Exception Handling (Microsoft) and other languages also provide the finally clause, which really simplifies exception handling by providing a single, localized point of exit and cleanup (Python's not allowing you to use the except and finally clauses in the same block is annoying, though).

One last thing: choosing to investigate all those topics before getting to work on your game virtually guarantees that you won't get to work on your game for a long time to come. I say take the knowledge you have now, make a small game. Learn some more, use that new knowledge in the next game. Nothing solidifies learned theory and technique like applying it to real-world problems.

Happy hacking.
October 22, 2005 03:34 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

XNA

1529 views

...

642 views

Physics demo

1255 views

Console launch...

1091 views

New project

1450 views

b day

1108 views

Source control

1277 views

More on Inform 7

1062 views

Logging

1208 views

Lines of code

1275 views
Advertisement