{"id":483,"date":"2018-06-15T19:15:27","date_gmt":"2018-06-15T18:15:27","guid":{"rendered":"http:\/\/pusling.com\/blog\/?p=483"},"modified":"2018-06-15T19:15:27","modified_gmt":"2018-06-15T18:15:27","slug":"partially-initialized-objects","status":"publish","type":"post","link":"https:\/\/pusling.com\/blog\/?p=483","title":{"rendered":"Partially initialized objects"},"content":{"rendered":"<p>I found this construct some time ago. It took some reading to understand why it worked. I&#8217;m still not sure if it is actually legal, or just works only because m_derivedData is not accessed in Base::Base.<\/p>\n<pre class=\"lang:c++ decode:true \" title=\"Partially initialized objects\" >struct Base {\r\n    std::string&amp; m_derivedData;\r\n    Base(std::string&amp; data) : m_derivedData(data) {\r\n    }\r\n};\r\n\r\nstruct Derived : public Base {\r\n    std::string m_data;\r\n    struct Derived() : Base(m_data), m_data(\"foo\") {\r\n    }\r\n};<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I found this construct some time ago. It took some reading to understand why it worked. I&#8217;m still not sure if it is actually legal, or just works only because m_derivedData is not accessed in Base::Base. struct Base { std::string&amp; m_derivedData; Base(std::string&amp; data) : m_derivedData(data) { } }; struct Derived : public Base { std::string [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4,11],"tags":[],"class_list":["post-483","post","type-post","status-publish","format-standard","hentry","category-english","category-kde","category-qt"],"_links":{"self":[{"href":"https:\/\/pusling.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pusling.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pusling.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pusling.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/pusling.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=483"}],"version-history":[{"count":1,"href":"https:\/\/pusling.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions"}],"predecessor-version":[{"id":484,"href":"https:\/\/pusling.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions\/484"}],"wp:attachment":[{"href":"https:\/\/pusling.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pusling.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pusling.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}