{"id":4432,"date":"2014-03-30T10:57:28","date_gmt":"2014-03-30T10:57:28","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-default-arguments-collection-of-common-programming-errors\/"},"modified":"2014-03-30T10:57:28","modified_gmt":"2014-03-30T10:57:28","slug":"problem-about-default-arguments-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-default-arguments-collection-of-common-programming-errors\/","title":{"rendered":"problem about default-arguments-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/cd05c493e7c2e241e814b66a9bf3d826?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\npmr<br \/>\nc++ design boolean default-arguments member-function<br \/>\nWe have several classes where a call to a member function may change state and sometimes not depending on a boolean with default value.A a;a.set( &#8220;foobar&#8221; );assert( a.changed() == true );versusA a;a.set( &#8220;foobar&#8221;, false );assert( a.changed() == false );Please note that those member functions are virtual. I would favor to use an alias to better read code and make a private member function still allowing the old method and give only the wrappers to the public:a.silentlySet( &#8220;foobar&#8221; ) {a.set( &#8220;foo<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7d8f1b63190014ebbeba10735c768d7b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser974967<br \/>\nc++ function-overloading default-arguments<br \/>\nMy program has a Car and CarManager class that looks similar to the following:#include &lt;list&gt;class Car { public:void Draw() { Draw(m_opacity); }void Draw(float opacity){}private:float m_opacity; };class CarManager { public:\/\/Draw cars using their m_opacity membervoid DrawCars() { for(auto i = m_cars.begin(); i != m_cars.end(); i++)i-&gt;Draw();}\/\/Draw cars using opacity argumentvoid DrawCars(float opacity){for(auto i = m_cars.begin(); i != m_cars.end(); i++)i-&gt;Draw(opacity);}private:std<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>pmr c++ design boolean default-arguments member-function We have several classes where a call to a member function may change state and sometimes not depending on a boolean with default value.A a;a.set( &#8220;foobar&#8221; );assert( a.changed() == true );versusA a;a.set( &#8220;foobar&#8221;, false );assert( a.changed() == false );Please note that those member functions are virtual. I would favor [&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-4432","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4432","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=4432"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4432\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}