After getting used to the var
keyword in C#, I'm starting to use the auto
keyword in C++11. They both determine type by inference and are useful when you just want the compiler to figure out the type for you. Here's the C++11 port of your code:
#include <array>
#include <string>
using namespace std;
array<string, 3> strarr = {"ram", "mohan", "sita"};
for(auto str: strarr) {
listbox.items.add(str);
}