<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>What is a protected abstract virtual base pure virtual private destructor?</title>
		<link>http://www.allegro.cc/forums/view/478186</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 09 Apr 2005 03:04:10 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well I came across this line in somebody&#39;s quote at some website. I thought that it was a joke. But out of curiosity I did a Google. And woah!! The first result was bang on. I found this explanation -</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Q What is a protected abstract virtual base pure virtual private destructor? (Van Der Linden, Peter. Expert C Programming. Page 327)</p><p>A It is a pure virtual private destructor that is inherited from a protected abstract virtual base. In other words, a destructor function that can only be called by members or friends of the class (private), and is assigned a 0 (pure virtual) in the base class (abstract base) that declares it, and will be defined later / overriden in a derived class that shares the multiply-inherited base (virtual base) in a protected way.</p></div></div><div class="source-code snippet"><div class="inner"><pre><span class="k1">class</span> y <span class="k2">:</span> <span class="k1">virtual</span> <span class="k1">protected</span> x
<span class="k2">{</span>
private:
  ~y<span class="k2">(</span><span class="k2">)</span> <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span><span class="k2">;</span>

<span class="k1">class</span> z <span class="k2">:</span> <span class="k1">protected</span> y <span class="k2">{</span> <span class="k2">}</span><span class="k2">;</span>
</pre></div></div><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>In this instance, ~y() is a protected abstract virtual base pure virtual private destructor of z.</p></div></div><p>
  Next half hour was like <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /><img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /><img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /><img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /><img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /><img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /><img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /> Zoinked!</p><p> Oke fine! I get it or perhaps not ! But please somebody tell me what is the use of such a construct ? Is there any use at all or it is just a hack to bother candidates in interviews ?? <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p> Thank you in advance.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Pradeepto Bhattacharya)</author>
		<pubDate>Thu, 07 Apr 2005 14:34:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>i would use it instead of a plunger, when my toilet is blocked, C++ reference books make a good alternative.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A J)</author>
		<pubDate>Thu, 07 Apr 2005 14:51:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ask one of the Finnish guys around here what the longest word in their language is, and they&#39;ll come up with quirks that are for finnish what the above is for C++. Anyway, who knows, there might be scenarios where you actually use such a monster.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Thu, 07 Apr 2005 14:53:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
We can do that in Swedish, too. Finnish and Swedish both do concatenation rather than stacking, so we can create potentially infinitely long connected words. Of course, they&#39;re nonsensical and no one would use them, but we can do it. Example:</p><p>Buffer overrun = buffertöverskridning<br />Buffer overrun handler = buffertöverskridningshanterare<br />Buffer overrun handler exception = buffertöverskridningshanterarundantag<br />Buffer overrun handler exception error identification number = buffertöverskridningshanterarundantagsfelsidentifikationsnummer.</p><p>And so on.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Thu, 07 Apr 2005 16:00:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>But that&#39;s only connected words. In Finnish we can twist and stretch one single word. <a href="http://www.allegro.cc/forums/view_thread.php?_id=446287#target">Beat that!</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Thu, 07 Apr 2005 16:19:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://www.apostate.com/programming/c-tech.html">Here</a> is the link where I found the explanation.<br /> <br />  Still looking for an answer though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Pradeepto Bhattacharya)</author>
		<pubDate>Thu, 07 Apr 2005 16:22:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Still looking for an answer though.
</p></div></div><p>
Don&#39;t. Should you ever find yourself using such a word, see a shrink. Should you ever find yourself using such a construct, revise your program layout.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Thu, 07 Apr 2005 17:16:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You know, you would not likely use it at all. Basically it is saying that the destructor can be called only by friends or members of the class, but that the class itself will not define the destructor, one of the children will define it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ReyBrujo)</author>
		<pubDate>Thu, 07 Apr 2005 18:28:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, actually.  The fact being if you do that you&#39;ll never be able to define a destructor.  All destructors from subclasses will attempt to call the destructor of the base class, and will have major problems.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Wetimer)</author>
		<pubDate>Fri, 08 Apr 2005 00:25:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">class</span> BaseClass <span class="k2">{</span>
  private:
    <span class="k1">virtual</span> ~BaseClass<span class="k2">(</span><span class="k2">)</span> <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span><span class="k2">;</span>

<span class="k1">class</span> DerivedClass: <span class="k1">public</span> BaseClass <span class="k2">{</span>
  private:
    <span class="k1">virtual</span> ~BaseClass<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span> <span class="c">/* do stuff */</span> <span class="k2">}</span>
<span class="k2">}</span><span class="k2">;</span>
</pre></div></div><p>
...dunno ...would this work?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 08 Apr 2005 19:33:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre>test.cpp:1: warning: `<span class="k1">class</span> BaseClass<span class="s">' only defines a private destructor and</span>
<span class="s">   has no friends</span>
<span class="s">test.cpp:8: error: destructor `BaseClass'</span> must match <span class="k1">class</span> name `DerivedClass<span class="s">'</span>
<span class="s">test.cpp:6: warning: `class DerivedClass'</span> only defines a <span class="k1">private</span> destructor <span class="k1">and</span>

   has no friends
test.cpp: In destructor `<span class="k1">virtual</span> DerivedClass::~DerivedClass<span class="k2">(</span><span class="k2">)</span><span class="s">':</span>
<span class="s">test.cpp:3: error: `BaseClass::~BaseClass()'</span> is <span class="k1">private</span>
test.cpp:8: error: within <span class="k1">this</span> context
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Wetimer)</author>
		<pubDate>Sat, 09 Apr 2005 03:04:10 +0000</pubDate>
	</item>
</rss>
