final class in c++

前端 未结 7 1631
轮回少年
轮回少年 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:24

    And of course the proper way to do it today is to use the final keyword. For example:

    class Foo final {
    public:
      Foo() {}
      ~Foo() {}
    
      void bar() {
         // ...
      }
    };
    
    0 讨论(0)
提交回复
热议问题