Inherit from const class

后端 未结 8 1711
不思量自难忘°
不思量自难忘° 2021-01-12 00:24

I would like to inherit from a class with the const specifier like this:

class Property
{
    int get() const;
    void set(int a);
};

class Co         


        
8条回答
  •  佛祖请我去吃肉
    2021-01-12 01:06

    Use a data member or private base class instead of public base class.

    Then you control the access to that member.

    You can make the Property thing an abstract interface if you need polymorphic behavior.

提交回复
热议问题