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

前端 未结 5 1682
长情又很酷
长情又很酷 2020-12-25 13:32

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 d

5条回答
  •  北海茫月
    2020-12-25 14:11

    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.

提交回复
热议问题