#include <cstdio>    // for printf.

struct b
{
	virtual void f() { std::printf("in b\n"); }
};

struct d1 : b
{
	virtual void f() override { std::printf("in d1\n"); }
};

struct d2 : b
{
	virtual void f() override { std::printf("in d2\n"); }
};

struct unko_f final
{
	b *pb;
	unko_f(b *pb) : pb(pb) {}
	void operator=(b *pb) { this->pb = pb; }

	void operator()() { this->pb->f(); }
};

struct unko_del final
{
	b *pb;
	void (b::*pbf)();

	unko_del(b *pb, void (b::*pbf)()) : pb(pb), pbf(pbf) {}

	void operator()() { ( (this->pb) ->* (this->pbf) ) (); }
};

int main()
{
	d1 i1;
	unko_f kusof(&i1);
	kusof();

	d2 i2;
	kusof = &i2;
	kusof();

	unko_del del1(&i1, &b::f);
	del1();

	std::getchar();
}
