Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Exception Speicfication

Exception Speicfication

Scheduled Pinned Locked Moved C / C++ / MFC
c++
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vibindia
    wrote on last edited by
    #1

    class Exception{}; //warning C4290: C++ Exception Specification ignored void ExceptionSepcification()throw(Exception) { throw Exception(); } void WithOutExceptionSepcification() { throw Exception(); } void main() { try { ExceptionSepcification(); //Or call WithOutExceptionSepcification(); } catch(Exception& e) { cout<<"Exception caught"; } } Both the Function ExceptionSepcification and WithOutExceptionSepcification throws Exception. The what does the throw in Below statement makes difference void ExceptionSepcification()throw(Exception)

    VIBIN "Fool's run away,where angle's fear to tread"

    M F 2 Replies Last reply
    0
    • V vibindia

      class Exception{}; //warning C4290: C++ Exception Specification ignored void ExceptionSepcification()throw(Exception) { throw Exception(); } void WithOutExceptionSepcification() { throw Exception(); } void main() { try { ExceptionSepcification(); //Or call WithOutExceptionSepcification(); } catch(Exception& e) { cout<<"Exception caught"; } } Both the Function ExceptionSepcification and WithOutExceptionSepcification throws Exception. The what does the throw in Below statement makes difference void ExceptionSepcification()throw(Exception)

      VIBIN "Fool's run away,where angle's fear to tread"

      M Offline
      M Offline
      Matthew Faithfull
      wrote on last edited by
      #2

      Essentially it's just a hint to the Compiler bu the exact answer is both Compiler and Compiler Option Switch dependent. See MSDN[^] for an explanation of Microsoft's attempts at C++ Exception support.

      Nothing is exactly what it seems but everything with seems can be unpicked.

      1 Reply Last reply
      0
      • V vibindia

        class Exception{}; //warning C4290: C++ Exception Specification ignored void ExceptionSepcification()throw(Exception) { throw Exception(); } void WithOutExceptionSepcification() { throw Exception(); } void main() { try { ExceptionSepcification(); //Or call WithOutExceptionSepcification(); } catch(Exception& e) { cout<<"Exception caught"; } } Both the Function ExceptionSepcification and WithOutExceptionSepcification throws Exception. The what does the throw in Below statement makes difference void ExceptionSepcification()throw(Exception)

        VIBIN "Fool's run away,where angle's fear to tread"

        F Offline
        F Offline
        Florin Crisan
        wrote on last edited by
        #3

        In brief, don’t bother with exception specifications. Even experts don’t bother. The main problems with exception specifications are that they’re only “sort of” part of the type system, they don’t do what most people think, and you almost always don’t want what they actually do. http://www.gotw.ca/gotw/082.htm[^] http://herbsutter.spaces.live.com/blog/cns!2D4327CC297151BB!149.entry[^]

        Florin Crisan

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups