{"id":327,"date":"2009-08-03T12:05:47","date_gmt":"2009-08-03T11:05:47","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=327"},"modified":"2009-08-03T12:05:47","modified_gmt":"2009-08-03T11:05:47","slug":"execution-order","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2009\/08\/03\/execution-order\/","title":{"rendered":"Execution order"},"content":{"rendered":"<p>Execution order of programs code is very much a vital thing to understand and where some fault finds will take a long while to figure out.  Basically like in maths where there is a order of calculating, well in coding structures and also multitasking and multi-threading setups the execution order may be incorrect for lines of code.<\/p>\n<p>Here is some examples, the first is when will a function be called and the later when post\/pre incrementation will take place.<\/p>\n<pre lang=\"cpp\">\r\n#include <iostream>\r\n\r\nusing namespace std;\r\n\r\nint value =1;\r\n\r\nint setvalue2()\r\n{\r\n\tcout << \"setting value\"<<endl;\r\n\tvalue = 2;\r\n\treturn value;\r\n}\r\n\r\nint returnvalue()\r\n{\r\n\tcout << \"renting value\"<< endl;\r\n\treturn value;\t\r\n}\r\n\r\nint main()\r\n{\r\n\t\/\/ depending on the order of execution the value may be\r\n\t\/* setvalue2 called first\r\n\t\t(setvalue2 = 2 \/ returnvalue = 2) = 1\r\n\t   returnvalue called first\r\n\t\t(setvalue2 = 2 \/ returnvalue = 1) = 2\r\n\t*\/\r\n\tcout << setvalue2() \/ returnvalue() << endl;\r\n\r\n\tint i;\r\n\ti = i++ - ++i;\t\/\/ not sure what i will be because the pre\/post increaments \r\n\ti = 3, i++, i++; \/\/ i will equal 5 because in correct order.\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Execution order of programs code is very much a vital thing to understand and where some fault finds will take a long while to figure out. Basically like in maths where there is a order of calculating, well in coding structures and also multitasking and multi-threading setups the execution order may be incorrect for lines &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2009\/08\/03\/execution-order\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Execution order<\/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":[7],"tags":[10,9,8,398,400],"class_list":["post-327","post","type-post","status-publish","format-standard","hentry","category-c_and_cpp","tag-c","tag-gcc","tag-gnu","tag-linux","tag-windows"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/327","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=327"}],"version-history":[{"count":1,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/327\/revisions"}],"predecessor-version":[{"id":328,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/327\/revisions\/328"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}