Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: Not Selected
more ▼

asked Feb 08 '15 at 09:50 AM in C++ Programming

avatar image

6 1 4 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

more ▼

answered Feb 08 '15 at 07:18 PM

avatar image

88 3 8 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

more ▼

answered Feb 09 '15 at 12:51 PM

avatar image

121 2 57 12

avatar image ngrts Feb 10 '15 at 04:22 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question