Jump to content
  • Advertisement

Ubik

Sign in to follow this  
  • entries
    101
  • comments
    122
  • views
    58287

C++ Exceptions

Sign in to follow this  
Will F

155 views

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!