Access to method pointer to protected method?

前端 未结 6 637
情歌与酒
情歌与酒 2020-12-03 17:27

This code:

class B {
 protected:
  void Foo(){}
}

class D : public B {
 public:
  void Baz() {
    Foo();
  }
  void Bar() {
    printf(\"%x\\n\", &B::F         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 18:22

    Why can I call a protected method but not take its address?

    This question has an error. You cannot do a call either

    B *self = this;
    self->Foo(); // error either!
    

    As another answer says if you access the non-static protected member by a D, then you can. Maybe you want to read this?


    As a summary, read this issue report.

提交回复
热议问题