TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How to refresh on modern features of C++?

101 点作者 ctb_mg超过 10 年前
I first learned C++ 14 years ago and have only used it in a non-trivial fashion on one or two short projects since then.<p>Today, reading an article on popular C++ myths [1], I now realized there are a TON of things I didn&#x27;t realize modern C++ can do now. auto, unique_ptr, for_each, and range-for loops were new to me. I&#x27;m not 100% certain if all of these were recent additions to the language.<p>What are some things I can do to brush up on the modern features of C++?<p>[1] https:&#x2F;&#x2F;isocpp.org&#x2F;blog&#x2F;2014&#x2F;12&#x2F;myths-1

23 条评论

jerv超过 10 年前
Herb Sutter, one of the most prolific C++ experts out there, recently gave a talk on Modern C++ [1]. In the beginning of his talk, he states that every C++ developer should read a &quot;Tour of C++&quot; [2] by Bjarne Stroustrup, the original designer of C++.<p>I recently read it and it&#x27;s great. The book has less than 200p, but still covers the most important parts of C++11, albeit not in great detail (the reader is pointed to &quot;The C++ Programming Language&quot; by the same author for that). Read it! And watch the youtube video in [1].<p>[1] <a href="https://www.youtube.com/watch?v=xnqTKD8uD64" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=xnqTKD8uD64</a> [2] <a href="http://www.amazon.com/Tour-In-Depth-Series-Bjarne-Stroustrup/dp/0321958314" rel="nofollow">http:&#x2F;&#x2F;www.amazon.com&#x2F;Tour-In-Depth-Series-Bjarne-Stroustrup...</a>
评论 #8788669 未加载
评论 #8788904 未加载
tjr超过 10 年前
I&#x27;ve not read it, but the author&#x27;s other books have been well-regarded for years:<p><a href="http://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996/" rel="nofollow">http:&#x2F;&#x2F;www.amazon.com&#x2F;Effective-Modern-Specific-Ways-Improve...</a>
评论 #8788763 未加载
评论 #8788715 未加载
评论 #8788653 未加载
vowelless超过 10 年前
Watch the videos from GoingNative and CppCon. Speakers like Bjarne and Herb constantly talk about &quot;whats new in Modern C++&quot;. Watch Andrei&#x27;s talks for sure!<p><a href="http://channel9.msdn.com/Events/GoingNative/GoingNative-2012" rel="nofollow">http:&#x2F;&#x2F;channel9.msdn.com&#x2F;Events&#x2F;GoingNative&#x2F;GoingNative-2012</a><p><a href="http://channel9.msdn.com/Events/GoingNative/2013" rel="nofollow">http:&#x2F;&#x2F;channel9.msdn.com&#x2F;Events&#x2F;GoingNative&#x2F;2013</a><p><a href="https://www.youtube.com/user/CppCon" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;user&#x2F;CppCon</a>
optymizer超过 10 年前
The first few chapters of The C++ Programming Language by Bjarne Stroustrup 4th edition go through a tour of C++11 that will quickly show you how to use modern C++ techniques. The rest of the book can be used as a reference to learn more about specific features.
评论 #8788942 未加载
throwawayaway超过 10 年前
Well at the risk of stating the obvious, there&#x27;s a lot of armchair programmer style &quot;read this&quot;, &quot;watch this&quot; instruction here. It&#x27;s much better to do something concrete.<p>Go and do a trivial project in it, cppreference.com and cplusplus.com have c++11 tags on the new features. I&#x27;m sure you&#x27;ve had ideas recently and I&#x27;m sure the project is less trivial than you thought!<p>I think looking at language features first is &quot;a solution looking for a problem&quot; attitude.
评论 #8789214 未加载
评论 #8800107 未加载
评论 #8789429 未加载
danieljh超过 10 年前
If you want to learn by examples, check out the following repositories:<p><a href="https://github.com/daniel-j-h/cpp14-snippets" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;daniel-j-h&#x2F;cpp14-snippets</a> <a href="https://github.com/daniel-j-h/cpp11-snippets" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;daniel-j-h&#x2F;cpp11-snippets</a><p>(Disclaimer: the C++14 version is still missing proper references to the official C++14 standard)
pmelendez超过 10 年前
As other said, Meyer&#x27;s book is highly recommended.<p>Also, this talk would give you a very general overview of the new features of the language:<p><a href="http://channel9.msdn.com/Events/GoingNative/2013/Opening-Keynote-Bjarne-Stroustrup" rel="nofollow">http:&#x2F;&#x2F;channel9.msdn.com&#x2F;Events&#x2F;GoingNative&#x2F;2013&#x2F;Opening-Key...</a><p>Another book that can be a refresh introduction would be:<p><a href="http://www.amazon.com/Tour-C--Depth/dp/0321958314/ref=sr_1_1?ie=UTF8&amp;qid=1419355516&amp;sr=8-1&amp;keywords=tour+of+c%2B%2B" rel="nofollow">http:&#x2F;&#x2F;www.amazon.com&#x2F;Tour-C--Depth&#x2F;dp&#x2F;0321958314&#x2F;ref=sr_1_1...</a>
w8rbt超过 10 年前
You may like to read and search the questions on stackoverflow. They have a lot of C++11 and C++14 questions and code examples and many of the contributors are very experienced with C++.<p><pre><code> http:&#x2F;&#x2F;stackoverflow.com&#x2F;tags&#x2F;c%2b%2b11&#x2F;info http:&#x2F;&#x2F;stackoverflow.com&#x2F;tags&#x2F;c%2b%2b14&#x2F;info </code></pre> I use C++ almost daily. I love it. I&#x27;ve used it for many years now. Having said that, I try to avoid the newer standards unless I absolutely must use them.<p>Don&#x27;t get me wrong. The new features are great. I love nullptr, fixed width integers, to_string, stol, etc. but I sometimes work in environments with very old compilers that don&#x27;t offer these features. And when the only code you have is written for C++11 or newer, it can take a great deal of time and effort to make your code work on the older systems.<p>Also, if what you need is in the standard, then don&#x27;t use any external libraries. There are a lot of great libraries out there (Boost, Crypto++, etc.), but they add complexity and build dependencies and can cause all sorts of support issues. If you add Boost only because you need to parse arguments, then you&#x27;re really causing yourself and developers who come after you more trouble than it&#x27;s worth. So every time you think you need an external library, think twice and talk it over with other, more experienced developers.<p>When I need more features than the older standard provides, I&#x27;ll use a newer standard, but I strive to only use the exact features I need (don&#x27;t go wild and convert your entire code to C++11). And as a very last resort, I&#x27;ll use an external library (but only a mature, widely used one) when I cannot easily write what I need with std C++.<p>Hope this helps. And whatever you decide, I&#x27;m sure you&#x27;ll enjoy working with C++.
评论 #8789294 未加载
thepumpkin1979超过 10 年前
Similar story here, I played with C++ back in 1998 and then again in 2007.<p>After reading these two books it definitely changed the way I see and work with C++, I fell in love with it.<p>So reading old code-bases is very common, you still need to understand the old C++ anyway:<p>Professional C++, Wrox, Jan 2005<p>Then to get yourself up to speed with C++11 and C++14:<p>Professional C++ 3rd Edition - Wrox, Sept 2014
acqq超过 10 年前
Go to the Stroustrup&#x27;s site, the page with the contents of his &quot;C++ 4th ed&quot; book contains even the full drafts of the &quot;Tour of C++&quot; part of the book.<p><a href="http://www.stroustrup.com/4thContents.html" rel="nofollow">http:&#x2F;&#x2F;www.stroustrup.com&#x2F;4thContents.html</a>
shmerl超过 10 年前
Just read the new edition of C++ Programming language by Bjarne Stroustrup ;)<p>Some things are hard to come by in any shorter sources. And at times you have to dig into the standard.<p>An example of rather obscure thing in C++ which changed in C++11 (sequencing): <a href="http://en.cppreference.com/w/cpp/language/eval_order" rel="nofollow">http:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;language&#x2F;eval_order</a><p>And another thing which can be pretty confusing without carefully reading the standard. Copy elision vs move constructors...<p>See <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf" rel="nofollow">http:&#x2F;&#x2F;www.open-std.org&#x2F;jtc1&#x2F;sc22&#x2F;wg21&#x2F;docs&#x2F;papers&#x2F;2011&#x2F;n324...</a> § 12.8 (Copying and moving class objects), #32 - 33
评论 #8788777 未加载
Stubb超过 10 年前
I&#x27;m in the same boat and working through &quot;A Tour of C++&quot; by Stroustrup. It highlights the new features you&#x27;re talking about with concise examples but doesn&#x27;t flesh out the details. So you&#x27;ll know that there&#x27;s an often-better way to do certain things using the new language features. You&#x27;ll need another reference for assistance with the details, often Stack Overflow examples suffice.<p>&quot;Effective Modern C++&quot; goes more into the details and is next on my queue.<p>I&#x27;ve done a bunch of Ruby, Java, and some Lisp programming since my last stint with C++. It feels like a whole new language.
pagade超过 10 年前
I have read and I would highly recommend C++ Primer 5th edition. Although my purpose was <i>also</i> to brush up old(?) features of C++. It covers everything except multi-threading.<p>If you just want to skim - A Tour of C++ should suffice.
discardorama超过 10 年前
A (maybe unrelated) question about companies like Google and Faceook, which are C++ powerhouses: how many (if any) of the C++11 or C++14 features have they approved for use in production code?
评论 #8789772 未加载
wglb超过 10 年前
The Scott Meyers books on Effective C++ are excellent.
thdn超过 10 年前
Take a look at Stephan T. Lavavej aka STL series at C9, <a href="http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-" rel="nofollow">http:&#x2F;&#x2F;channel9.msdn.com&#x2F;Series&#x2F;C9-Lectures-Stephan-T-Lavave...</a><p>Totally worthy.
ramgorur超过 10 年前
same with me, I am a very old c++ coder, learned during 2001-2002. Now I am doing TA at a graduate school, instructing a course on c++. It helped me to learn a lot of new stuffs on c++11.<p>&quot;C++ Primer&quot;, by Lippman is the book that we try to follow.
评论 #8789800 未加载
gdy超过 10 年前
Don&#x27;t like Scott Meyer&#x27;s books, but this pdf has chance to be good: <a href="http://www.artima.com/shop/overview_of_the_new_cpp" rel="nofollow">http:&#x2F;&#x2F;www.artima.com&#x2F;shop&#x2F;overview_of_the_new_cpp</a>
pmorici超过 10 年前
Almost all of those new features are part of the C++11 standard so just get a reference that specifically says it has been updated for C++11. There is a list of C++ books on stack overflow.
sedeki超过 10 年前
How about C++ Primer 5th edition?
diarg超过 10 年前
You want even MORE features in C++?. You have made Stroustrup happy.
lyhkop超过 10 年前
aaa
qwerta超过 10 年前
Start with QT libs.<p>I hate C++ with passion for almost two decades. But I recently started working on KDE sub-project and found it very nice.