{"id":3891,"date":"2014-03-30T06:11:24","date_gmt":"2014-03-30T06:11:24","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/new-operator-in-c-collection-of-common-programming-errors\/"},"modified":"2014-03-30T06:11:24","modified_gmt":"2014-03-30T06:11:24","slug":"new-operator-in-c-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/new-operator-in-c-collection-of-common-programming-errors\/","title":{"rendered":"new operator in c++-Collection of common programming errors"},"content":{"rendered":"<p>When the <code>new<\/code> operator allocates memory dynamically, it returns a pointer to that memory (similar to how <code>malloc()<\/code> works in C).<\/p>\n<p>In C++, every non-static method has access to the current object it is called on (else C++ programmers around the world would be in serious trouble). This is an &#8220;implicit argument&#8221; of the methods, in the constructors as well, and one can access it through the keyword <code>this<\/code>.<\/p>\n<p>What the sentence means is that after creating the object, the operator will call the constructor <strong>on the memory it just allocated.<\/strong> Because this is the only thing that makes sense. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When the new operator allocates memory dynamically, it returns a pointer to that memory (similar to how malloc() works in C). In C++, every non-static method has access to the current object it is called on (else C++ programmers around the world would be in serious trouble). This is an &#8220;implicit argument&#8221; of the methods, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3891","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3891","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3891"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3891\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}