The simple form:
std::string data[] = {"ram","mohan","sita"};
std::for_each(data,data+3,std::bind1st(std::mem_fun(&Y::add), &(listbox.items)));
An example in action:
#include <algorithm>
#include <string>
#include <iostream>
#include <functional>
class Y
{
public:
void add(std::string value)
{
std::cout << "Got(" << value << ")\n";
}
};
class X
{
public:
Y items;
};
int main()
{
X listbox;
std::string data[] = {"ram","mohan","sita"};
std::for_each(data,data+3,std::bind1st(std::mem_fun(&Y::add), &(listbox.items)));
}