How would I convert this code to C++?
string[] strarr = {\"ram\",\"mohan\",\"sita\"};
foreach(string str in strarr) {
listbox.items.add(str);
}
Using boost is the best option as it helps you to provide a neat and concise code, but if you want to stick to STL
void listbox_add(const char* item, ListBox &lb)
{
lb.add(item);
}
int foo()
{
const char* starr[] = {"ram", "mohan", "sita"};
ListBox listBox;
std::for_each(starr,
starr + sizeof(starr)/sizeof(char*),
std::bind2nd(std::ptr_fun(&listbox_add), listBox));
}