Jump to content
  • Advertisement


Sign in to follow this  
  • entries
  • comments
  • views

C++ Exceptions

Sign in to follow this  
Will F


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.
Sign in to follow this  

1 Comment

Recommended Comments

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.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!