class and arrays

i have a button class with SetText() and GetText() and MouseClick(lambda variable) members.
see these line:

1
2
3
button a[2];
a[0].SetText("hello 1");
a[1].SetText("hello 2");


now how can i change\update the MouseClick for be like these:

1
2
3
4
a.MouseClick=[](int index)
{
     Messagebox(NULL, a[index].GetText().c_str(), "button caption", MB_OK)
};
Last edited on
1
2
3
4
5
6
7
8
a[0].MouseClick=[](int index)
{
     Messagebox(NULL, a[index].GetText().c_str(), "button caption", MB_OK)
};
a[1].MouseClick=[](int index)
{
     Messagebox(NULL, a[index].GetText().c_str(), "button caption", MB_OK)
};
?
Last edited on
sorry no. imagine that the MouseClick() on all 'a', have the same value, but uses a 'a' caption.
like the calculator uses the number of caption button
Topic archived. No new replies allowed.