Making a template parameter a friend?

前端 未结 3 1600
忘掉有多难
忘掉有多难 2020-12-01 04:31

Example:

template
class Base {
public:
    Base();
    friend class T;
};

Now this doesn\'t work... Is there a way of doing

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 05:12

    Do you really need to do this? If you want to prevent someone from deriving from your class, just add a comment and make the destructor non-virtual.

提交回复
热议问题