thank for your reply. can this be aplied to string array too?
string A[4] = {"cat", "dog", "fish", "bird"};
string B[2] = {"cat", "snake"};
because i still didnt get how the declaration of "set<int>" work. I had run your code too, and it give this error:
set.cpp:13:26: error: in C++98 ‘A’ must be initialised by constructor, not by ‘{...}’
set.cpp:13:26: error: could not convert ‘{1, 2, 4, 6}’ from ‘<brace-enclosed initialiser list>’ to ‘std::set<int>’
set.cpp:14:22: error: in C++98 ‘B’ must be initialised by constructor, not by ‘{...}’
set.cpp:14:22: error: could not convert ‘{1, 7, 9}’ from ‘<brace-enclosed initialiser list>’ to ‘std::set<int>’
As far as I can tell, Peter87's code is using C++11 uniform initialisation. Have a look at the std::set constructors (on this site's reference) to see how to construct them without curly braces.
Or, figure out how to turn on C++1114 on your compiler. If you are not forced to use outdated compiler, chances that you simply did not enble all moder features of the language.