#include #include using namespace std ; void printString(const string& str1) { cout << str1 << endl ; } int main() { //Create a std::function object called f1. Store the function //printString in it. function< void(const string&) > f1 = printString ; const string str1 = "Hooray. Almost end of Semester." ; cout << "Result of f1: " ; f1( str1 ) ; //Create a std::function object called f2. Store //a lambda expression that does the same thing //as printString. The capture clause is empty and //it takes a single argument of type "const string&" //printString in it. function< void(const string&) > f2 = [](const string& str1 ) { cout << str1 << endl ; } ; cout << "Result of f2: " ; f2( str1 ) ; return 0; }