{"id":745,"date":"2010-02-17T11:56:03","date_gmt":"2010-02-17T11:56:03","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=745"},"modified":"2010-02-17T11:56:03","modified_gmt":"2010-02-17T11:56:03","slug":"enum-what-are-they","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2010\/02\/17\/enum-what-are-they\/","title":{"rendered":"enum &#8211; what are they"},"content":{"rendered":"<p>A enum type is basically a array on constant elements that you can assign to words a integer value.<\/p>\n<p>To give a example, lets say that you have a different type of car<\/p>\n<pre lang=\"cpp\">\r\nenum cars { VAUX, FORD, LAND };\r\n<\/pre>\n<p>which in turn mean that  VAX = 0 and FORD = 1 and LAND = 2, arrays start from 0 of course.<\/p>\n<p>So you can use the code as <\/p>\n<pre lang=\"cpp\">\r\nenum cars car = VAUX;\r\nif (car == VAUX) printf(\"Vauxhall car\\n\");\r\n<\/pre>\n<p>which would make more sense than saying<\/p>\n<pre lang=\"cpp\">\r\nint car = 0;\r\nif (car == 0) printf(\"Vauxhall car\\n\");\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A enum type is basically a array on constant elements that you can assign to words a integer value. To give a example, lets say that you have a different type of car enum cars { VAUX, FORD, LAND }; which in turn mean that VAX = 0 and FORD = 1 and LAND = &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2010\/02\/17\/enum-what-are-they\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">enum &#8211; what are they<\/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":[],"class_list":["post-745","post","type-post","status-publish","format-standard","hentry","category-c_and_cpp"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/745","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=745"}],"version-history":[{"count":1,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/745\/revisions"}],"predecessor-version":[{"id":746,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/745\/revisions\/746"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}