{"id":4334,"date":"2013-10-07T05:00:30","date_gmt":"2013-10-06T18:00:30","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=4334"},"modified":"2013-10-07T05:00:30","modified_gmt":"2013-10-06T18:00:30","slug":"c-xcode-oop-exceptions-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/c-xcode-oop-exceptions-primer-tutorial\/","title":{"rendered":"C++ Xcode OOP Exceptions Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/Exceptions\/CPlusPlus_Exceptions_Primer.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"C++ Xcode OOP Exceptions Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/Exceptions\/CPlusPlus_Exceptions_Primer.jpg\" title=\"C++ Xcode OOP Exceptions Primer Tutorial\" \/><\/a><p class=\"wp-caption-text\">C++ Xcode OOP Exceptions Primer Tutorial<\/p><\/div>\n<p>Our C++ Xcode OOP Exceptions Tutorial presented here opens the door to the idea of handling error exceptions when using C++.   The two major areas I&#8217;ve found where error handling is really important are with mathematical calculations and with input\/output scenarios (which includes file handling).   Let&#8217;s see below some information about Exception Handling from Wikipedia:<\/p>\n<blockquote><p>Exception handling is the process of responding to the occurrence, during computation, of exceptions \u2013 anomalous or exceptional events requiring special processing \u2013 often changing the normal flow of program execution. It is provided by specialized programming language constructs or computer hardware mechanisms.<\/p>\n<p>In general, an exception is handled (resolved) by saving the current state of execution in a predefined place and switching the execution to a specific subroutine known as an exception handler. If exceptions are continuable, the handler may later resume the execution at the original location using the saved information. For example, a floating point divide by zero exception will typically, by default, allow the program to be resumed, while an out of memory condition might not be resolvable transparently.<\/p>\n<p>Alternative approaches to exception handling in software are error checking, which maintains normal program flow with later explicit checks for contingencies reported using special return values or some auxiliary global variable such as C&#8217;s errno or floating point status flags; or input validation to preemptively filter exceptional cases.<\/p><\/blockquote>\n<p>Click on picture to see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/Exceptions\/CPlusPlus_Exceptions_Primer.jpg'>C++ using XCode<\/a> programming showing an error handling scenario where we act in a proactive way to circumvent any errors to do with finding the cube root of a negative number (using the <a target=_blank title='Exceptions in C++' href='http:\/\/www.cplusplus.com\/doc\/tutorial\/exceptions\/'>throw<\/a> method), and then looking at two mathematical checks which are not error throwers (via use of <a target=_blank title='isnan in C++' href='http:\/\/www.cplusplus.com\/reference\/cmath\/isnan\/'>isnan<\/a> and <a target=_blank title='isinf in C++' href='http:\/\/www.cplusplus.com\/reference\/cmath\/isinf\/'>isinf<\/a>) leaving default <a target=_blank title='Exceptions in C++' href='http:\/\/www.cplusplus.com\/doc\/tutorial\/exceptions\/'>try\/catch exception logic<\/a> for other scenario types.<\/p>\n<p>Link to some downloadable programming C++ source code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/Exceptions\/main.cpp_GETME' title='Download me'>main.cpp<\/a> for use.<\/p>\n<p>Link to Exception Handling information &#8230; <a target=_blank title='Exceptions' href='http:\/\/en.wikipedia.org\/wiki\/Exception_handling'>from Wikipedia from which quote above comes<\/a>.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d4334' onclick='var dv=document.getElementById(\"d4334\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=C%2B%2B\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d4334' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Our C++ Xcode OOP Exceptions Tutorial presented here opens the door to the idea of handling error exceptions when using C++. The two major areas I&#8217;ve found where error handling is really important are with mathematical calculations and with input\/output &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/c-xcode-oop-exceptions-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,28,37,40],"tags":[176,393,404,875,997,1319,1473],"class_list":["post-4334","post","type-post","status-publish","format-standard","hentry","category-elearning","category-oop","category-tutorials","category-xcode","tag-c","tag-error-handling","tag-exceptions","tag-oop","tag-programming","tag-tutorial","tag-xcode"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/4334"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=4334"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/4334\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=4334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=4334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=4334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}