#include #include "prelude.h" #include "ref_count.h" using std::cout; using std::endl; // A <-- B X <-- Y struct A { virtual void f() const =0; }; struct B : public A { void f() const { cout << "B::f()" << endl; } }; struct X { virtual void g() const =0; }; struct Y : public X { void g() const { cout << "Y::g()" << endl; } }; struct fun_from_A_to_Y : public CFunType { Y* operator()( A* ) const { return new Y; } }; int main() { Fun1 fay = makeFun1( fun_from_A_to_Y() ); Fun1 fbx = fay; // woohoo! fbx( new B )->g(); //Fun1 oops = fbx; Fun1 oops = explicit_convert1(fbx); // Fun1 crap = fbx; return 0; }