I didn't know inheritance had such a performance impact...
I guess you could either perform a static_cast (but there is much likely some undefined behaviour here...), or use templates:
template <class T>class A{public: A(T *i_ptr, void (T::*i_func_ptr)()); virtual void function() = 0;private: T *m_ptr; void (T::*m_func_ptr)();};class B: public A<B>{public: B(); void function();};template <class T>A<T>::A(T *i_ptr, void (T::*i_func_ptr)()) : m_ptr(i_ptr), m_func_ptr(i_func_ptr){ (m_ptr->*m_func_ptr)(); // crash: pure virtual method called}B::B() : A<B>(this, &B::function){}void B::function(){ std::cout << "function invoked\n";}
I have no idea why this crashes, I guess you should even be able to get away with not passing the 'this' pointer...it's not working but it gives you a clue (maybe someone else knows what is wrong?).
Also, if this is only to avoid inheritance...is that even worth it?