Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think we need some cleanup.</p> <ol> <li><p>the friend declaration seems ill-placed, from the comment you want CGconstructor_base to be able to access CardGenerator attributes: if this is so, then the friend declaration goes into CardGenerator (I say who I consider as my friends, you do not declare yourself as being someone I consider a friend).</p></li> <li><p>Why do you need friend anyway ? It would be much better if as in the tutorial you used a structure and then stuffed the attributes into CGconstructor_base. This way you will be able to access them from CardGenerator naturally without this supplementary line. When you can do without the 'friend' keyword you should (usual caveat: if doing so does not increase the cost too much).</p></li> <li><p>you want <strong>PRIVATE</strong> inheritance here, this is a detail implementation. Only use public inheritance (or protected even) when OTHER classes/methods will need to know use you 'as-a' base.</p></li> </ol> <p>In a nutshell:</p> <pre><code>struct CGconstructor_base { template&lt;class ArgumentPack&gt; CGconstructor_base(ArgumentPack const&amp; args);/*tutorial says to put code in this function */ cg_type1 cg_attr1; cg_type2 cg_attr2; }; // don't forget this class CardGenerator:private CGconstructor_base {}; </code></pre> <p>I do wonder why 'inheritance' has been chosen by boost instead of (I think) cleaner composition. It is so much easier to abuse inheritance (and require Multiple-Inheritance)... I suppose it is worth a subject of its own though.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload