title: Declare and use a pointer to member function in another class
body: <p>I have this error, when I try to use a pointer to member function to a different class.</p>
  
  <pre>
  Error : sources/common/OurMenu.cpp: 
    In member function ‘void OurMenu::menuNavigation()’: sources/common/OurMenu.cpp:336:36: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in 
    ‘((OurMenu*)this)->OurMenu::_buttons.std::vector::at >(((std::vector::size_type)((OurMenu*)this)->OurMenu::_actualLine))->Button::doIt (...)’, e.g. ‘(... ->* ((OurMenu*)this)->OurMenu::_buttons.std::vector::at >(((std::vector::size_type)((OurMenu*)this)->OurMenu::_actualLine))->Button::doIt) (...)’
       _buttons.at(_actualLine)->doIt();
  </pre>
  
  <p>That's my code:</p>
  
  <p><strong>OurMenu.hh</strong></p>
  
  <pre><code>class                           OurMenu
  {
   private:
    GraphicLib                    *_window;
    OurGame                       *_game;
    gdl::Geometry                 _background;
    std::vector&lt;gdl::Texture*&gt;    _textures;
    std::vector&lt;Button*&gt;          _buttons;
    int                           _actualLine;
    int                           _time;
  
  public:
    [...]
    void                          menuNavigation();
    void                          gameSetting();
  };
  </code></pre>
  
  <p><strong>Button.hh</strong></p>
  
  <pre><code>class                   Button
  {
   private:
    Bloc                  *_select;
    Bloc                  *_notSelect;
  
   public:
    Button(const float &amp;x, const float &amp;y, gdl::Geometry *back,
       gdl::Texture *tx, gdl::Texture *txS, glm::vec3 const &amp;scale, void (OurMenu::*ptr)());
    ~Button();
  
    void                  (OurMenu::*doIt)();
    void                  isSelect();
    void                  isDeselect();
    Bloc                  *getSelect() const;
    Bloc                  *getNotSelect() const;
  };
  </code></pre>
  
  <p>Button Declaration    </p>
  
  <pre><code> Button  *solo = new Button(2, 7, &amp;_background, _textures.at(1), _textures.at(7), 
                             glm::vec3(0.0025, 0.0022, 0), &amp;OurMenu::gameSetting);
  </code></pre>
  
  <p>Function call</p>
  
  <pre><code>solo-&gt;doIt();
  </code></pre>
  
  <p><strong>Button.cpp</strong>    </p>
  
  <pre><code>Button::Button(const float &amp;x, const float &amp;y, gdl::Geometry *back, 
                gdl::Texture *tx, gdl::Texture *txS, glm::vec3 const &amp;scale, void (OurMenu::*ptr)())
  {
    _select = new Bloc(0, 0, back, txS);
    _select-&gt;rotate(glm::vec3(1, 1, 0), 180);
    _select-&gt;setScale(scale);
    _select-&gt;setX(x);
    _select-&gt;setY(y);
    _select-&gt;setZ(1);
  
    _notSelect = new Bloc(0, 0, back, tx);
    _notSelect-&gt;rotate(glm::vec3(1, 1, 0), 180);
    _notSelect-&gt;setScale(scale);
    _notSelect-&gt;setX(x);
    _notSelect-&gt;setY(y);
    _notSelect-&gt;setZ(-1);
    doIt = ptr;
  }
  </code></pre>