{"id":4233,"date":"2014-03-30T09:24:54","date_gmt":"2014-03-30T09:24:54","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/determining-size-of-an-overloaded-c-class-collection-of-common-programming-errors\/"},"modified":"2014-03-30T09:24:54","modified_gmt":"2014-03-30T09:24:54","slug":"determining-size-of-an-overloaded-c-class-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/determining-size-of-an-overloaded-c-class-collection-of-common-programming-errors\/","title":{"rendered":"Determining size of an overloaded C++ class-Collection of common programming errors"},"content":{"rendered":"<p>If you are able to change source classes&#8217; design, you can totally replace dynamic polymorphism (which uses virtual functions) with static polymorphism and use the CRTP idiom:<\/p>\n<pre><code>template \nclass Base\n{\npublic:\n    int getSize()\n    { return sizeof(TDerived); }\n\n    void print()\n    {\n          std::cout\n             getSize()<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you are able to change source classes&#8217; design, you can totally replace dynamic polymorphism (which uses virtual functions) with static polymorphism and use the CRTP idiom: template class Base { public: int getSize() { return sizeof(TDerived); } void print() { std::cout getSize()<\/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-4233","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4233","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=4233"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4233\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}