final class in c++

前端 未结 7 1629
轮回少年
轮回少年 2020-12-31 08:36
class Temp
{
private:
    ~Temp() {}
    friend class Final;
};

class Final : virtual public Temp
{
public:
     void fun()
     {
         cout<<\"In base\";         


        
7条回答
  •  有刺的猬
    2020-12-31 09:01

    The derived class does not call the private destructor of the base class, hence it does not need visibility.

    Make your constructors private and only provide a static generator function.

提交回复
热议问题