I want to fill a constexpr table with pointers to call the pointers later. The given example shows only one entry.
I run into two problems:
1) It is not possible for me to find a correct syntax to write a pointer a member class object which is able to initialized to an object of a derived class.
2) I could not use the pointer to call the virtual functions.
#include <iostream>
using namespace std;
class State { public: virtual void Do() const {} };
class S1: public State { public: virtual void Do() const { cout << "S1 Do" << endl; } };
class S2: public State { public: virtual void Do() const { cout << "S2 Do" << endl; } };
class A 
{   
    public:
        S1 s1; 
        S2 s2; 
};  
class B
{   
    private:
        static constexpr A a{};
        static constexpr State A::*state { &A::S2 }; // < do not work! 
    public:
        void Do() const
        {   
            (a.*state).Do();    // is it possible to have a pointer to any State class to call virtual functions?  
        }   
};  
constexpr A B::a;
int main()
{   
    B b;
    b.Do();
    return 0;
}   
 
    