How to implement an interface with two abstract methods by a lambda expression?
How to implement an interface with two abstract methods by a lambda expression?
14917-Aug-2023
Updated on 18-Aug-2023
Home / DeveloperSection / Forums / How to implement an interface with two abstract methods by a lambda expression?
How to implement an interface with two abstract methods by a lambda expression?
Aryan Kumar
18-Aug-2023Sure, I can help you with that.
To implement an interface with two abstract methods by a lambda expression, you can use the
auto
keyword. Theauto
keyword tells the compiler to infer the type of the lambda expression.The following code is an example of how to implement an interface with two abstract methods by a lambda expression:
C++
In this code, the
myInterface
variable is a lambda expression that implements theIMyInterface
interface. TheMethod1()
andMethod2()
methods of themyInterface
variable are implemented by the lambda expression.