|
What is a protected abstract virtual base pure virtual private destructor? |
Pradeepto Bhattacharya
Member #1,340
May 2001
|
Well I came across this line in somebody'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 - Quote: Q What is a protected abstract virtual base pure virtual private destructor? (Van Der Linden, Peter. Expert C Programming. Page 327) 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. class y : virtual protected x { private: ~y() = 0; }; class z : protected y { }; Quote: In this instance, ~y() is a protected abstract virtual base pure virtual private destructor of z. Next half hour was like Zoinked! 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 ?? Thank you in advance. -- |
A J
Member #3,025
December 2002
|
i would use it instead of a plunger, when my toilet is blocked, C++ reference books make a good alternative. ___________________________ |
Tobias Dammers
Member #2,604
August 2002
|
Ask one of the Finnish guys around here what the longest word in their language is, and they'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. --- |
X-G
Member #856
December 2000
|
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're nonsensical and no one would use them, but we can do it. Example: Buffer overrun = buffertöverskridning And so on. -- |
Johan Halmén
Member #1,550
September 2001
|
But that's only connected words. In Finnish we can twist and stretch one single word. Beat that! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
Pradeepto Bhattacharya
Member #1,340
May 2001
|
Here is the link where I found the explanation. -- |
Tobias Dammers
Member #2,604
August 2002
|
Quote: Still looking for an answer though. Don'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. --- |
ReyBrujo
Moderator
January 2001
|
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. -- |
Wetimer
Member #1,622
November 2001
|
No, actually. The fact being if you do that you'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. <code>if(Windows.State = Crash) Computer.halt();</code> |
Tobias Dammers
Member #2,604
August 2002
|
class BaseClass { private: virtual ~BaseClass() = 0; }; class DerivedClass: public BaseClass { private: virtual ~BaseClass() { /* do stuff */ } }; ...dunno ...would this work? --- |
Wetimer
Member #1,622
November 2001
|
test.cpp:1: warning: `class BaseClass' only defines a private destructor and has no friends test.cpp:8: error: destructor `BaseClass' must match class name `DerivedClass' test.cpp:6: warning: `class DerivedClass' only defines a private destructor and has no friends test.cpp: In destructor `virtual DerivedClass::~DerivedClass()': test.cpp:3: error: `BaseClass::~BaseClass()' is private test.cpp:8: error: within this context
<code>if(Windows.State = Crash) Computer.halt();</code> |
|