{"id":329,"date":"2009-08-03T12:16:00","date_gmt":"2009-08-03T11:16:00","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=329"},"modified":"2009-08-03T12:16:00","modified_gmt":"2009-08-03T11:16:00","slug":"static-casting","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2009\/08\/03\/static-casting\/","title":{"rendered":"Static casting"},"content":{"rendered":"<p>Static casting is when you want to convert one type into another, static casting is used allot of the time without even knowing.  For example<\/p>\n<pre lang=\"cpp\">\r\nint value = 2;\r\nfloat t = float(value);\r\n<\/pre>\n<p>the float(value) is a static casting of converting one value into another.  Below is a full code example<\/p>\n<pre lang=\"cpp\">\r\n#include <iostream>\r\n\r\nusing namespace std;\r\nint main()\r\n{\r\n\tint i = 3;\r\n\t\/\/ the float(<value)> is basically a static cast from a interger value into a float\r\n\tcout << float(i) << endl;\r\n\tcout << static_cast<float>(i) << endl;\r\n}\r\n<\/pre>\n<p>It is very small since static_cast'ing is very basic in nature, but the only problem is that you have to check to make sure that there is a error e.g not NULL.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Static casting is when you want to convert one type into another, static casting is used allot of the time without even knowing. For example int value = 2; float t = float(value); the float(value) is a static casting of converting one value into another. Below is a full code example #include using namespace std; &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2009\/08\/03\/static-casting\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Static casting<\/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-329","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\/329","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=329"}],"version-history":[{"count":1,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/329\/revisions"}],"predecessor-version":[{"id":330,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/329\/revisions\/330"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}