Getting address of class member function and calling it from pointer : <p>Trying to make LCD screen library for Arduino.
Made a class "ScreenHandlerClass". This has S1_stat() and S2_stat() functions that will write different things on LCD screen.
There's a "statScreenPointer", that I'm trying to make to call functions, however it does not work properly.</p>

<p>I tried to follow this guide:
<a href="https://stackoverflow.com/questions/25453259/calling-member-function-pointers">Calling Member Function Pointers</a>
That's the closest solution to my problem.
I tried:</p>

<p>this->*statScreenPointer</p>

<pre><code>Error compiling project sources
ScreenHandler.cpp: 14:26: error: invalid use of non-static member function
   this-&gt;*statScreenPointer
</code></pre>

<p>Other I tried:
this->*statScreenPointer()</p>

<pre><code>Error compiling project sources
ScreenHandler.cpp: 14:27: error: must use '.*' or '-&gt;*' to call pointer-to-member function in '((ScreenHandlerClass*)this)-&gt;ScreenHandlerClass::statScreenPointer (...)', e.g. '(... -&gt;* ((ScreenHandlerClass*)this)-&gt;ScreenHandlerClass::statScreenPointer) (...)
   this-&gt;*statScreenPointer()
Build failed for project 'v1'
</code></pre>

<p>CODE:</p>

<pre><code>// ScreenHandler.h

#ifndef _SCREENHANDLER_h
#define _SCREENHANDLER_h

#include "arduino.h"
#include "debug.h"
#include "vezerles.h"
#include "EncoderHandler.h"
#include &lt;LiquidCrystal_I2C.h&gt;

extern EncoderHandlerClass encoder;
extern LiquidCrystal_I2C lcd;

enum screenType {
    S1,
    S2
};

extern screenType screen;

class ScreenHandlerClass
{
private:
    void logic();
    void (ScreenHandlerClass::*statScreenPointer)();

public:
    ScreenHandlerClass();
    void init();
    void handle();
    void S1_stat();
    void S2_stat();
};

#endif

</code></pre>

<pre><code>// ScreenHandler.cpp
#include "ScreenHandler.h"

screenType screen;

ScreenHandlerClass::ScreenHandlerClass() {}

void ScreenHandlerClass::init() {

    statScreenPointer = &amp;ScreenHandlerClass::S1_stat;
    this-&gt;*statScreenPointer; // ----&gt; how to call this properly?
    lcd.setCursor(0, 1);
    lcd.print("init"); // this is DISPLAYED
}

void ScreenHandlerClass::handle()
{
    logic();
}

void ScreenHandlerClass::logic()
{
    // some logic for lcd screen switching
}

void ScreenHandlerClass::S1_stat() {
    lcd.setCursor(0, 0);
    lcd.print("S1_stat"); // this is NOT DISPLAYED
}

void ScreenHandlerClass::S2_stat() {
    // some other text for lcd
}
</code></pre>

<pre><code>// v1.ino
#include "debug.h"
#include "global.h"
#include &lt;TimerOne.h&gt;                  
#include &lt;LiquidCrystal_I2C.h&gt;          
#include "MillisTimer.h"
#include "vezerles.h"
#include "lcd.h"
#include "EncoderHandler.h"
#include "ScreenHandler.h"

extern EncoderHandlerClass encoder;
ScreenHandlerClass scrh;
LiquidCrystal_I2C lcd(0x3F, 20, 4);

void setup() {
    Serial.begin(9600);
    encoder.initButton(PIND, PD4, 500);
    lcd.init();
    lcd.backlight();
    scrh.init();

}
void loop() {
    // some code
}


</code></pre>
