
On Thu, Jan 13, 2005 at 01:45:59PM +0100, Daniel Wessl?n wrote:
Jonathan Wakely skrev:
On Thu, Jan 13, 2005 at 12:49:33PM +1000, kalin wrote:
This is a simpler way of preventing inheritance:
class Finaliser { protected: Finaliser(){} };
class Final : private virtual Finaliser { // rest of class as normal };
[...] There's another problem with Final that lets you derive from it in a class with user-defined constructors, if you know how. Our wiki where I work offers a chocolate bar to anyone who points it out but noone's claimed it from me yet :)
class WillCompile : public Final, virtual Finaliser { public: WillCompile() {} };
Exactly. I was fairly surprised to see Dr Dobbs publishing it without that caveat. I guess it works to tell users they _shouldn't_ derive from it, but as often happens you can get around it if you really want to, and you can't always stop people who deliberately try to breakthe rules.
Will you mail the chocolate bar to me then?
I didn't expect it to be a challenge for anyone reading this list but if you want some british chocolate let me know offlist :-) jon -- "Do what thou wilt shall be the whole of the law" - The Doctrines of Thelema