#include <iostream>
class A {
char (*provider)();
public:
A(char (*p)()) : provider(p) {}
char Get() { return provider(); }
};
char foo1() { return '1'; }
char foo2() { return '2'; }
int main(int argc, char* argv[])
{
A x(foo1);
A y(foo2);
std::cout << x.Get() << y.Get();
return 0;
}
Login in to like
Login in to comment