Reply to post:

What's all the C Plus Fuss? Bjarne Stroustrup warns of dangerous future plans for his C++

Fibbles

It's not far off that really. C++ is a statically typed language so you need to provide a type in your code or explicitly tell the compiler to deduce it from the value passed.

for ( auto& x : v )

If you look at the above range based for you can see that the colon is equivalent to 'in'. The only non obvious bit to somebody who uses another language is the 'auto&'. The 'auto' just tells the compiler to deduce the type since it knows what 'v' contains and therefore knows the type of 'x'. The '&' tells the compiler that it should not make a copy of the element from the container but just use a reference back to the original object.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon