Wednesday, October 31, 2007

What is a protected abstract virtual base pure virtual private destructor?

A protected abstract virtual base pure virtual private destructor.

This is one of the funny question and very less answered one. It may be a very long sentence. But the code needed for making a protected abstract virtual base pure virtual private destructor is quite simple.
The below code is the one which makes a protected abstract virtual base pure virtual private destructor

Program:

class BaseClass // An abstract class
{
public:
virtual void MakeAbstract() = 0;
};

// A class derived as an protected abstract virtual base
class AbstractBase : virtual protected BaseClass
{
private:
void MakeAbstract(){;}
// A pure virtual private destructor
virtual ~AbstractBase() = 0;
friend class Derived;
};

AbstractBase::~AbstractBase()
{

}
class Derived : protected AbstractBase
{

};

int main(int argc, _TCHAR* argv[])
{
// You can definitely make an object of class Derived
Derived obj;
return 0;
}


Explanation:

In the above program AbstractBase::~AbstractBase() can be called as a protected abstract virtual base pure virtual private destructor. Let us see how it can be called so.

1. The class AbstractBase is derived as "virtual protected" from an "abstract base" class. So we can call class AbstractBase as a "protected abstract virtual base".

2. Now let us check the destructor of class AbstractBase. It is made as a "pure virtual private" one. So we can call it as a "pure virtual private destructor".

3. Now combining both, we can call the destructor of AbstractBase as "protected abstract virtual base pure virtual private destructor"


Use:

This question can measure the knowledge in C++. Practically it wont have much of a use in implementation point of view. This question was made to prove that C++ is too complex and weird. But when we see the code for such a big definition it serves in the opposite way. Its quite easy to write long sentences in very few line of codes.

23 comments:

Anonymous said...

Here, ``~AbstractBase()`` is a protected abstract virtual base pure virtual private destructor for ``Derived`` object, isn't it?



#include <iostream>

class AbstractBase // Abstract class, no possible instances
{
virtual ~AbstractBase() = 0; // A pure virtual private destructor
friend class Derived; // the only possible descendant
};

AbstractBase::~AbstractBase() {
std::cout << "AbstractBase::~AbstractBase()" << std::endl;
}

// Here, ``~AbstractBase()`` is a protected abstract virtual base pure virtual private destructor, isn't it?
class Derived : virtual protected AbstractBase { };

int main() {
//! AbstractBase ab; // ``AbstractBase`` is abstract!
Derived obj; // You can definitely make an object of class Derived
}

dlandauer said...

In case it still matters to you, this exact phrase is explained in Peter van der Linden's 1994 book "Expert C Programming".

Anonymous said...

cheapest viagra in uk viagra and alcohol buy sublingual viagra online viagra larger forever cheapest viagra in uk fda on viagra buy viagra cheap levitra vs viagra viagra benefits pharmacy viagra viagra and alcohol viagra lawyer columbus pharmacy viagra viagra suppliers in the uk

Anonymous said...

Hey,

I am regular visitor of this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]Plenty of useful information on amalp.blogspot.com. Let me tell you one thing guys, some time we really forget to pay attention towards our health. Are you really serious about your weight?. Recent Research points that nearly 80% of all USA adults are either fat or weighty[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Hence if you're one of these citizens, you're not alone. Infact many among us need to lose 10 to 20 lbs once in a while to get sexy and perfect six pack abs. Now next question is how you can achive quick weight loss? [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss[/url] is really not as tough as you think. You need to improve some of you daily habbits to achive weight loss in short span of time.

About me: I am blogger of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also mentor who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effective weight loss.

Anonymous said...

Artistically done is richer reconsider than well said.

Anonymous said...

Artistically done is better than extravagantly said.

Anonymous said...

Lovingly done is richer reconsider than well said.

Anonymous said...

Well done is well-advised b wealthier than spectacularly said.

Anonymous said...

Well done is sick than comfortably said.

Anonymous said...

Lovingly done is sick than spectacularly said.

Anonymous said...

Splendidly done is better than well said.

Anonymous said...

A man who dares to barrens anyone hour of time has not discovered the value of life.

[url=http://www.flexiscale.com/forum/member.php?u=1320]Jenna[/url]


Linsey

Anonymous said...

We should be meticulous and perceptive in all the advice we give. We should be extraordinarily aware in giving opinion that we would not dream up of following ourselves. Most of all, we ought to avoid giving advisor which we don't imitate when it damages those who transport us at our word.

dewalt

[url=http://dewalt-16.webs.com/apps/blog/]dewalt[/url]

buy viagra said...

hello, thanks for all!!
viagra online
generic viagra

Anonymous said...

A human beings begins scathing his perceptiveness teeth the senior often he bites off more than he can chew.

Anonymous said...

To be a good charitable being is to procure a amiable of openness to the world, an cleverness to group undeterminable things beyond your own restrain, that can govern you to be shattered in unequivocally outermost circumstances for which you were not to blame. That says something exceedingly impressive relating to the fettle of the righteous autobiography: that it is based on a conviction in the fitful and on a willingness to be exposed; it's based on being more like a shop than like a jewel, something fairly dainty, but whose very item handsomeness is inseparable from that fragility.

Anonymous said...

To be a noble lenient being is to from a amiable of openness to the far-out, an cleverness to trust aleatory things beyond your own manage, that can take you to be shattered in unequivocally outermost circumstances for which you were not to blame. That says something uncommonly impressive about the condition of the righteous life: that it is based on a trustworthiness in the uncertain and on a willingness to be exposed; it's based on being more like a shop than like a jewel, something fairly tenuous, but whose acutely special handsomeness is inseparable from that fragility.

Anonymous said...

Exercise ferments the humors, casts them into their adapted channels, throws bad redundancies, and helps nature in those secret distributions, without which the association cannot subsist in its vigor, nor the typification fake with cheerfulness.

Anonymous said...

n everyone's sustenance, at some occasion, our inner pep goes out. It is then bust into flame at hand an be faced with with another magnanimous being. We should all be thankful for those people who rekindle the inner spirit

nifty erotic stories lesbian said...

Just because Ineed you now doesnt mean I wont kill you later, she spat. UNIDENTIFIED FEMALE Its wrong.
adult stories to read online
true sex stories confessions
animal beastiality stories
hot virgin sex stories
bestiality cumshot stories
Just because Ineed you now doesnt mean I wont kill you later, she spat. UNIDENTIFIED FEMALE Its wrong.

vivek singh said...

Awesome job! The feedback presented was extremely helpful. Lets hope you maintain the great work executed.
locksmiths fort worth
Nashville Locksmiths
Locksmith Walnut Creek CA
Palo Alto locksmith
Locksmith Palo Alto
Locksmith Palo Alto
Locksmith Palo Alto CA
pembroke pines locksmith
fort worth locksmith
Locksmith Hialeah FL
fort worth locksmith
fort worth locksmith
fort worth locksmith
locksmith Aventura FL
locksmith Aventura FL
locksmith aventura
locksmith aventura
mesquite tx locksmith
mesquite locksmith
mesquite locksmith
locksmith aventura
mesquite tx locksmith
aventura locksmiths
locksmith aventura
mesquite locksmith

Anonymous said...

Hi, guantanamera121212

Anonymous said...

не факт