c++ - List initializer -


I am trying to declare an Iterator type std :: initializer_list as described in

But I always get this error:

  Error: 'Iterator' 'std :: initializer_list & lt; Int & gt; Is not a member of  

Does someone guide me what kind of an iterator to std :: initializer_list ?

Edit:

For example this code will not work. Besides, the compiler I use supports the new standard draft

  int findcommon (std :: initializer_list & lt; int & gt; nums) {std :: initializer_list & lt; Int & gt; :: iterator; For (this = nums.begin (); it! = Nums.end (); ++ this) {std :: cout & lt; & Lt; * This is & lt; & Lt; Std :: endl; } Return 1; }  

You must add

  #include & LT; Initializer_list & gt;  

And for this example perhaps

  #include  

Also make sure that you are using -std = c ++ 0x to switch to g ++ and you can get at least G ++ Version 4.4 is required. When using compilers with MacPortes, the compiler is called G ++ - MP4.5 or G ++ - MP4.4 . (wrong belief).

I've seen some recently fixed bugs related to the initializer_list , so I recommend getting the latest version of GCC, 4.5.1. Because while using this version I'm able to compile both of my examples without problems.


Comments