Tuesday, 13 August 2013

Is it possible to create lambda methods of a particular class?

Is it possible to create lambda methods of a particular class?

For instance I have
class A {
public:
int x, y;
int(*func)();
};
and I would like to make that func be something like
int main()
{
A a;
a.func = [this](){return x + y;};
}
or something like that. That would mean that I can create method "func"
during runtime and decide what it is. Is it possible in C++?

No comments:

Post a Comment