How do I call a pointer-to-member-function?

前端 未结 4 1621
南旧
南旧 2020-12-01 15:12

I\'m getting a compile error (MS VS 2008) that I just don\'t understand. After messing with it for many hours, it\'s all blurry and I feel like there\'s something very obvio

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 15:41

    Just to chime in with my own experience, I've come across an error in g++ caused by this statement:

      (this -> *stateHandler)() ;
    

    Where stateHandler is a pointer to a void member function of the class referenced by *this. The problem was caused by the spaces between the arrow operator. The following snippet compiles fine:

    (this->*stateHandler)() ;
    

    I'm using g++ (GCC) 4.4.2 20090825 (prerelease). FWIW.

提交回复
热议问题