A netizen asked:
"
In a class, there is a member variable static set <int> set. How to use a 1000 element to initialize it?
"
The initialization of special member variables in a class is very skillful. I wrote a blog post on this issue:
Initialization of member variables of Special Data Types
However, this blog does not include the question raised by the above user. The following code is provided:
# Include <set> # include <iostream> using namespace STD; Class test {PRIVATE: static set <int> set; public: static void print () {for (set <int >:: iterator iter = set. begin (); iter! = Set. end (); ++ ITER) {cout <* ITER <Endl ;}}; set <int> Init () {set <int> TMP; for (INT I = 0; I <1000; ++ I) {TMP. insert (I) ;}return TMP ;}set <int> test: Set (Init ()); // note that set <int> int main (INT argc, char ** argv) {test: Print (); Return 0;} must be included first ;}
From: http://blog.csdn.net/pathuang68/article/details/7745657