Access private elements of object of same class

后端 未结 4 430
无人及你
无人及你 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:28

    It is redundant and unnecessary. Moreover, I get the following warning in g++

    warning: class ‘Foo’ is implicitly friends with itself
    

提交回复
热议问题