C++ Syntax Guide?

I am good in C++ concepts but I’m having hard time in understanding C++ syntax.
Like in this example why “:elem” is written before curly braces.

class Vector { public: 
Vector(int s) :elem{new double[s]}, sz{s} { }  

And this is a different for loop syntax.

for (auto& x : v) ++x;  

Can you guide me where can I learn this type of advanced syntax?

Easy one first: That’s C++11’s new range based for loop. 1-(Epic range based for loop blog) 2-(range-based for loop) 3-(Epic’s coding standard about range based for loop)

So that “:elem” stuff is part of basic c++ constructor semantics, used poorly. For your reference: member initializer list.

Follow UE coding standard. Than you would have been able to see whats going on. Probably a good college text book updated with C++11/14. Though only as far as Epic uses the C++11 features.

I learned C++11 syntax through Stroustrup’s book. If you already have a working knowledge of C++, it’s a great book as it goes into detail on this stuff in the first few chapters. http://www.amazon.com/The-Programming-Language-4th-Edition/dp/0321563840/ref=dp_ob_title_bk

That’s an advanced book. Someone familiar with C++ concepts but not syntax would not know what to look up. With the question about the constructor initializer: a function with the same name as the class is a constructor, very basic c++ knowledge. So look up constructors. You can’t do that if you don’t know the basics…

I would go for beginner: Programming: Principles and Practice Using C++ (2nd Edition) by Stroustrup

Intermediate: C++ Primer (5th Edition) by Lippman

Possibly even the standard Deitel+Deitel C++ college textbook.

And than “Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14” by Myers before the advanced book.