Thursday, June 14

Exceptions

Last weekend was really busy, I barly got a chance to play any video games between the XNA Tutorials, and the additional FullSail homework; more work was given on the conecutive Monday and Tuesday.

On Monday I was given a fairly rude awakening as it's a lot harder to keep up with normal classes when you don't get extra practice. The topics covered in PG3 were Templates and a review of Linked Lists. Here are a few intresting things I picked out from my notes.


Container – the usual name used for Linked Lists or objects that hold other objects.
Every virtual function is put into the virtual function table
Because the virtual keyword uses more memory we try to shun from it when it’s not appropriate
Templates need to be all inside the header file.
CCYA - Check Cover Your Ass. Check for copyright code.

and some useful VC++ shortcuts

CTRL K, S - surround your code with a snippet
CTRL K, K - Bookmark a section in the code
CTRL K, N - Move to the next bookmark


I did pretty well on the Practice Test for Physics, and things began to look up from there on. So that pretty much takes me to the today's topic, Exceptions. Although not a new topic for me, I had no idea how little I actually knew about the subject, but all's well that ends well as I aced the practical on the subject that night. This practicular practical was kind of fun to make and I'll remember to ask for permission to put it up for download. So that's it, I'll wrap up tonight and go to sleep with some more snippets from my notes.


  • Nesting classes

  • Nested Classes are not in any way related to one another

  • Access types are as default (classes::private)




  • Exceptions



  • throw

  • Syntax:                 throw variableName

  • The moment you throw, the stack unwinds

  • The stack unwinds until it reaches a catch

  • If there is no catch than the stack unwinds to main, after which it
    will call Terminate and then abort()



  • Exception Specification

  • throw(int it)

  • A way to better notify the catch what your trying to throw


  • http://blogs.msdn.com/larryosterman/archive/2006/03/22/558390.aspx

  • try



  • attempts, otherwise unwinds

  • catch (dataType)



  • if the dataType matches exactly, it’s as if the exception never happened

  • specifying a variable to dataType such as catch(dataType num) allows
    for manipulation of the thrown variable



  • catch(…) also known as ellipsis

  • will catch all dataTypes



  • can not be given a variable



  • throw bad_;



  • ex: throw bad_index(“Naughty subscript”);

  • #include <exception>



  • struct bad_index : public exception // : is a base list, public
    inheritance “is-a” an exception


  • bad_index(char const * const message) : exception(message)
    { }

  • .what()



  • by adding a (gcnew String(instance.what()) is a trick to go from managed
    to unmanaged exception handling.



  • finally()

  • will execute regardless of try / catch block

  • this will execute even after a re-      throw()

  • Only works in the focal



  • CTRL + F3



  • Set a keyword and search down



  • F3

  • Search Down Next

  • SHIFT + F3

  • Search Up Next

No comments: