C
Chameleon
How I must implement function 'func' to work the code below?
I guess that I need templates but I haven't a link to start.
I saw something like this in boost::thread but I didn't understand.
--------------------------------------------------------------
class A
{
public:
void operator()() { printf("enter A\n"); }
};
void afunc() { printf("enter afunc\n"); }
void func(void (*a)()) { a(); }
int main() {
A a;
func(afunc);
func(&a);
return 0;
}
I guess that I need templates but I haven't a link to start.
I saw something like this in boost::thread but I didn't understand.
--------------------------------------------------------------
class A
{
public:
void operator()() { printf("enter A\n"); }
};
void afunc() { printf("enter afunc\n"); }
void func(void (*a)()) { a(); }
int main() {
A a;
func(afunc);
func(&a);
return 0;
}