title: Use of non-static member function for this Arduino library
body: <p>In an Arduino project (C++) I use the <a href="https://github.com/VaSe7u/LiquidMenu" rel="nofollow noreferrer">LiquidMenu</a> library and I have difficulties to integrate this class in my own. The example provided are too simple for a real scenario.</p>
  <p>Some code that does not compile:</p>
  <p>main.cpp</p>
  <pre><code>const int rs = 3, en = 0, d4 = 4, d5 = 30, d6 = 12, d7 = 6;
  LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  
  Menu menu(&amp;lcd);
  
  void setup() { }
  
  void loop() { }
  </code></pre>
  <p>header</p>
  <pre><code>class Menu
  {
  public: 
      Menu(LiquidCrystal *lcd);        
  
  private:
      int _myvar;
  
      LiquidCrystal *_lcd;
      LiquidMenu _menu;
      LiquidScreen _screenSetCC1;
  
      LiquidLine line1_setupCC1;
      LiquidLine line2_setupCC1;
  
      void editIntPlus();
  };
  </code></pre>
  <p>cpp</p>
  <pre><code>Menu::Menu(LiquidCrystal *lcd) : _lcd(lcd), _menu(*_lcd),
      line1_setupCC1(0, 0, &quot;Set CC #1&quot;),
      line2_setupCC1(0, 1, _myvar)
  {
      
      line2_setupCC1.attach_function(1, editIntPlus);
  
      _screenSetCC1.add_line(line1_setupCC1);
      _screenSetCC1.add_line(line2_setupCC1);
      _menu.add_screen(_screenSetCC1);
  }
  
  void Menu::editIntPlus()
  {
      _myvar++;
  }
  </code></pre>
  <p>first error is:</p>
  <blockquote>
  <p>error: invalid use of non-static member function 'void Menu::editIntPlus()'</p>
  </blockquote>
  <p>But I cannot make that function static, otherwise I cannot access to <code>_myvar</code> anymore.
  The <a href="https://github.com/VaSe7u/LiquidMenu/tree/master/examples/A_hello_menu" rel="nofollow noreferrer">examples</a> are not useful because they put everything outside any class and it's against any basic rule of programming.</p>
  <p>Second question. In my menu I have dozens of <code>int</code> vars to set.
  I really don't want to create a lot of functions to increase or decrease each single var!</p>
  <p>How to retrieve, inside <code>editIntPlus()</code>, the current var being edited? The goal is to attach the same function to all the vars.</p>
  <p>I saw <a href="https://stackoverflow.com/questions/55094080/invalid-use-of-non-static-error-member-function-arduino">this</a> answer but:</p>
  <ol>
  <li><p>I cannot declare <code>editIntPlus</code> as <code>friend</code>:</p>
  <p>friend:
  void editIntPlus();</p>
  </li>
  </ol>
  <p>leads to:</p>
  <pre><code> include/menu.h:82:5: error: expected primary-expression before 'void'
       void editIntPlus();
       ^~~~
  </code></pre>
  <ol start="2">
  <li>as said before, I don't want to make my function <code>static</code> otherwise I cannot access anymore to the class members</li>
  </ol>