Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++, protected abstract virtual base pure virtual private destructor

Tags:

So, I found this quote today, can anyone explain?

"If you think C++ is not overly complicated, just what is a protected abstract virtual base pure virtual private destructor and when was the last time you needed one? — Tom Cargill"

like image 510
ra170 Avatar asked Sep 01 '10 13:09

ra170


1 Answers

I believe it is a private pure virtual destructor (I think that part is self-explanatory) that is part of an abstract base class, which you've used through protected virtual inheritance. .

 class Base
 {
    private:
        virtual ~Base() = 0;   /* A */
 };

 class Derived : protected virtual Base
 {
    private:
     ~Derived () {.......}    /* B */
 };

From the point of view of tag B, the line at tag A is a "protected abstract virtual base pure virtual private destructor",

Each of those three parts has its uses individually. I do not know of a design pattern that requires all three of the above parts, but there's nothing preventing their uses together.

like image 182
James Curran Avatar answered Oct 07 '22 16:10

James Curran