Access private elements of object of same class

后端 未结 4 401
无人及你
无人及你 2020-12-31 20:45

Is this legal? If not, will the following code allow this?

class Foo
{
    friend class Foo;
}
4条回答
  •  离开以前
    2020-12-31 21:16

    Classes friending themselves makes sense if they're templates, as each instantiation with distinct parameters is a different class.

提交回复
热议问题