{"id":1568,"date":"2011-03-08T22:55:42","date_gmt":"2011-03-08T22:55:42","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=1568"},"modified":"2011-06-07T09:46:54","modified_gmt":"2011-06-07T08:46:54","slug":"why-and-not-name-type","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2011\/03\/08\/why-and-not-name-type\/","title":{"rendered":"Why -> and not *name.type"},"content":{"rendered":"<p>When you are coding with pointers in c++ and you want to access the function\/variable from that pointer deferenced, how come you cannot use something like below.<\/p>\n<pre lang=\"cpp\">\r\nstruct typeT{\r\n   int value1;\r\n};\r\n\r\ntypeT* tt = new typeT;\r\n*tt.value1;\r\n<\/pre>\n<p>it is because the access element of the variable tt is higher in the compiler and thus it tries to equate<\/p>\n<pre lang=\"cpp\">\r\ntt.value1\r\n<\/pre>\n<p>first, which is not a good thing because the tt has not been de-referenced and thus it is just a memory address pointer to the actual object. so you need to do<\/p>\n<pre lang=\"cpp\">\r\n(*tt).value1\r\n<\/pre>\n<p>because like in maths the () will be equated first and then the access element part &#8220;.&#8221; and thus to make it easier<\/p>\n<pre lang=\"cpp\">\r\ntt->value1\r\n<\/pre>\n<p>will change to <\/p>\n<pre lang=\"cpp\">\r\n(*tt).value1\r\n<\/pre>\n<p>within the compiler.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you are coding with pointers in c++ and you want to access the function\/variable from that pointer deferenced, how come you cannot use something like below. struct typeT{ int value1; }; typeT* tt = new typeT; *tt.value1; it is because the access element of the variable tt is higher in the compiler and thus &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2011\/03\/08\/why-and-not-name-type\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Why -> and not *name.type<\/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-1568","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\/1568","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=1568"}],"version-history":[{"count":6,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/1568\/revisions"}],"predecessor-version":[{"id":1621,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/1568\/revisions\/1621"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=1568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=1568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=1568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}