stl - simulate virtual constructor in c++ -
In my application, I have to get some squares from the base class, the problem is that I want to implement derivative classification 3 C ++ is not a pure pure creator as a special producer implementation, it seemed quite desperate (I have been manually making the implementation of each class in order to ensure that special ctors have been implemented, not enough fun Have ) Had to examine.
Tomorrow I found a crazy way to emulate a virtual ctor's collaboration:
template
To declare all derived classes with syntax:
Class X: Private AbstractEnforcer
And even if this is not a problem, because Enforcer () never called method (and even something like that [I hope !!!]) My question is this: "There is a meaning to force the derivative class to use it (not with macros) without the ebertclass parameter parametrising (because it is only a derivative of Level
template class AbstractClass: Private AbstractEnforcer
Your solution does not resolve the problem because the code of the templated code Industry is not, and thus until the function you do not apply it manually - not to confirm the existence of the desired Knstrkshns.
What you can do, this method is from the constructor of your Enforcer:
template & lt; Class T & gt; Class Abbott Enforcer {Protected: Ebertechners () {Enforcer (); } Private: Static Zero Enforcer () {New T (Delete); Remove new t (* (new unsigned)); Remove new t (* (new unsigned int *, * (new Qestring)); } // Disable: Summoners (Contemporary Synopsis & amp; enf); }; Class abstract: Private Abrash Enhance & Lt; Abstraction Class & gt; {}; Int main () {abstract abstractclass c; }
Then, the compiler complains - the mission is complete.
Note that I have disabled copy creator so that there will be no way to bypass that check (by calling a different constructor.)
Edit - Non-leak infoser (): [As there is no need to make full use of dynamic allocation.]
Fixed Zero Enforcer () {TT (T (T) (T) T2 (Int (3)); T T3 (int (4), cuestring ()); }
Comments
Post a Comment