What is the difference between iterator with reference symbol, and without. (C++ loop) -


What is the difference between an iterator with Android? Symbol, and without it one, as shown in the examples given below 1 and 2 cases?

When should I use one or the other?

  #include & lt; Iostream & gt; # Include & lt; Vector & gt; Int main () {std :: vector & lt; Int & gt; V; V.push_back (1); V.push_back (2); // For Case 1: (Auto & amp; i = v.begin (); i! = V.end (); ++ i) {std :: cout & lt; & Lt; * I & lt; & Lt; Std :: endl; } // Case 2: for (auto i = v.begin (); i! = V.end (); ++ i) {std :: cout & lt; & Lt; * I & lt; & Lt; Std :: endl; }}  

Is it something with the creation of an Etherator object, and then what is available in the code block? I am very new to the itater.

The difference is that the first loop will not be compiled. )

(auto and amp; i = v.begin (); i! = V.end (); ++ i) {std :: cout & lt; & Lt; * I & lt; & Lt; Std :: endl; }

You created a temporary object back by member function initiated and tied it with non-conferencing reference.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -