#include <iostream>
extern "C"
{
typedef void call_back( const void*, int ) ;
void c_fun( call_back function, const void* arg1 )
{
for( int i = 0 ; i < 4 ; ++i ) function( arg1, i ) ;
}
}
struct A
{
void foo( int value ) const { std::cout << "void A::foo(int) const - value == " << value << '\n' ; }
};
extern "C"
{
void call_A_foo( const void* This, int v ) { static_cast< const A* >( This )->foo(v) ; }
}
int main()
{
A a ;
c_fun( call_A_foo, &a ) ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKZXh0ZXJuICJDIgp7CiAgICB0eXBlZGVmIHZvaWQgY2FsbF9iYWNrKCBjb25zdCB2b2lkKiwgaW50ICkgOwoKICAgIHZvaWQgY19mdW4oIGNhbGxfYmFjayBmdW5jdGlvbiwgY29uc3Qgdm9pZCogYXJnMSApCiAgICB7CiAgICAgICAgZm9yKCBpbnQgaSA9IDAgOyBpIDwgNCA7ICsraSApIGZ1bmN0aW9uKCBhcmcxLCBpICkgOwogICAgfQp9CgpzdHJ1Y3QgQQp7CiAgICB2b2lkIGZvbyggaW50IHZhbHVlICkgY29uc3QgeyBzdGQ6OmNvdXQgPDwgInZvaWQgQTo6Zm9vKGludCkgY29uc3QgLSB2YWx1ZSA9PSAiIDw8IHZhbHVlIDw8ICdcbicgOyB9Cn07CgpleHRlcm4gIkMiCnsKICAgIHZvaWQgY2FsbF9BX2ZvbyggY29uc3Qgdm9pZCogVGhpcywgaW50IHYgKSB7IHN0YXRpY19jYXN0PCBjb25zdCBBKiA+KCBUaGlzICktPmZvbyh2KSA7IH0KfQoKaW50IG1haW4oKQp7CiAgICBBIGEgOwogICAgY19mdW4oIGNhbGxfQV9mb28sICZhICkgOwp9Cg==