#include <iostream>
void hello1() {
std::cout << "Hello from normal\n";
}
auto hello2 = [] {
std::cout << "Hello from lamda\n";
};
class hello
{
public:
hello() {}
void operator()(std::string str) {
std::cout << "From functor " << str << std::endl<<std::endl;
}
};
void doIt(void(*f)()) {
f();
}
int main() {
hello1();
hello2();
hello hello3;
hello3("Hello");
doIt(hello1);
doIt(hello2);
doIt(hello3); //How can I do this?
}
I just started learning function objects and I cannot call function object from doIt function How can I call the last function object with doIt function?
Any help would be appreciated.