#include <iostream>
using namespace std;

struct IFoo{
	virtual void doWork() = 0;	
};

template<class T>
struct MemberFuncFoo : public IFoo{
	typedef void (T::*FuncType)();
	
	MemberFuncFoo(T *instance, FuncType memberFunc):
		m_instance(instance),
		m_memberFunc(memberFunc)
	{}
	
	virtual void doWork() override{
		(m_instance->*m_memberFunc)();
	}
	
private:
	T* m_instance;
	FuncType m_memberFunc;
};

struct Bar{
	void baz(){
		cout << "baz" << endl;		
	}
};

int main() {
	Bar bar;
	IFoo *ptr = new MemberFuncFoo<Bar>(&bar,&Bar::baz);
	ptr->doWork();
	// your code goes here
	return 0;
}