CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Created by Ketan Lalcheta
#include <iostream>
#include <functional>
using namespace std;
class Test
{
public:
// The setLambda and callLambda functions are static. They can operate without an instance of the class and interact with the static member variable lambda. Static member function to set the lambda
static void setLambda(function<void()> func)
{
lambda = func;
}
// Static member function to call the lambda
static void callLambda()
{
if (lambda)
{
lambda();
}
}
// Member functions to demonstrate usage
void display()
{
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run