如何精通C++ 摘自知乎和quora


如何精通C++ 摘自知乎和quora

已有 2014 次阅读 2015-10-3 20:47|个人分类:博文转载|系统分类:教学心得|关键词:学习C++|文章来源:转载

以下内容摘自知乎和quora上一些人的分享,请原谅我忘了记下原文地址和作者名字.....反正不是我写的。


C只读一本书《 The C Proguamming Language 》 读读C之父的著作,抛开老谭写的那本;



C++你可以读《C++ primer》,其实当你把这两本书读通后,我想对于C/C++语言的经验(除此之外要积累项目经验)来讲找工作是一定没问题的,可能还会比很多工作了的程序员在语言方面基础好。

如果想精通,结合我自己的体会,建议在C++方面阅读《effective c++》《more effective c++》这时至少语言的特性你会了解很多。之后可以把c++之父写的《C++ Programming Language》当做工具书来查看。

要想用好C++,有两个库不得不学,stl和boost。
我刚找完工作,说下自己的看法吧。
首先,精通就算了,如果在简历中写“精通C/C++”,一般会死的灰常灰常灰常难看。

其次,如果以大公司为目标,如果你就读学校够好,其实把《程序员面试宝典》看熟了理解了,笔试就没啥问题了。笔试题,千篇一律啊~~

第三,选择一个小方向深入研究准备面试。比如说熟悉STL,就要把相关的内存分配机制、回收机制、vector漏洞什么的搞清楚,推荐侯捷那本STL源码剖析。

最后,光有语言基础是不够的,还需要学会经典的算法,能顺利写出快排的代码这个难度就可以了。Linux环境也稍微熟悉一下。其实大公司校招更看重你的学习能力、思考问题的方法。语言只是工具,人人都能用笔,但不见得人人都能作画。

针对各个层次的C++程序员的参考书

A Tour of C++ (Bjarne Stroustrup) The "tour" is a quick (about 180 pages and 14 chapters) tutorial overview of all of standard C++ (language and standard library,and using C++11) at a moderately high level for people who already know C++ or at least are experienced programmers. This book is an extended version of the material that constitutes Chapters 2-5 of The C++ Programming Language, 4th edition.

The C++ Programming Language (Bjarne Stroustrup) (updated for C++11) The classic introduction to C++ by its creator. Written to parallel the classic K&R, this indeed reads very much alike it and covers just about everything from the core language to the standard library, to programming paradigms to the language's philosophy. (Thereby making the latest editions break the 1k page barrier.)[Review] The fourth edition (released on May 19, 2013) covers C++11.

C++ Standard Library Tutorial and Reference (Nicolai Josuttis) (updated for C++11) Theintroduction and reference for the C++ Standard Library. The second edition (released on April 9, 2012) covers C++11. [Review]

The C++ IO Streams and Locales (Angelika Langer and Klaus Kreft) There's very little to say about this book except that, if you want to know anything about streams and locales, then this is the one place to find definitive answers. [Review]

c++11参考

The C++ Standard (INCITS/ISO/IEC 14882-2011) This, of course, is the final arbiter of all that is or isn't C++. Be aware, however, that it is intended purely as a reference for experienced users willing to devote considerable time and effort to its understanding. As usual, the first release was quiteexpensive ( 300+US),butithasnowbeenreleasedinelectronicformfor
60US

Overview of the New C++ (C++11/14) (PDF only) (Scott Meyers) (updated for C++1y/C++14) These are the presentation materials (slides and some lecture notes) of a three-day training course offered by Scott Meyers, who's a highly respected author on C++. Even though the list of items is short, the quality is high.

针对初学者介绍: 如果你是一个编程方面的新手,或者有其他编程语言的经验但第一次接触C++的话,那么强烈推荐一下的书籍

C++ Primer * (Stanley Lippman, Josée Lajoie, and Barbara E. Moo) (updated for C++11) Coming at 1k pages, this is a very thorough introduction into C++ that covers just about everything in the language in a very accessible format and in great detail. The fifth edition (released August 16, 2012) covers C++11. [Review]

Accelerated C++ (Andrew Koenig and Barbara Moo) This basically covers the same ground as theC++ Primer, but does so on a fourth of its space. This is largely because it does not attempt to be an introduction to programming, but an introduction to C++ for people who've previously programmed in some other language. It has a steeper learning curve, but, for those who can cope with this, it is a very compact introduction into the language. (Historically, it broke new ground by being the first beginner's book using a modern approach at teaching the language.) [Review]

Thinking in C++ (Bruce Eckel) Two volumes; second is more about standard library, but still very good

Programming: Principles and Practice Using C++ (Bjarne Stroustrup) (updated for C++11/C++14) An introduction to programming using C++ by the creator of the language. A good read, that assumes no previous programming experience, but is not only for beginners.

有关编程技能的

Effective C++ (Scott Meyers) This was written with the aim of being the best second book C++ programmers should read, and it succeeded. Earlier editions were aimed at programmers coming from C, the third edition changes this and targets programmers coming from languages like Java. It presents ~50 easy-to-remember rules of thumb along with their rationale in a very accessible (and enjoyable) style. [Review]

Effective STL (Scott Meyers) This aims to do the same to the part of the standard library coming from the STL what Effective C++ did to the language as a whole: It presents rules of thumb along with their rationale. [Review]

中级c++程序员

More Effective C++ (Scott Meyers) Even more rules of thumb than Effective C++. Not as important as the ones in the first book, but still good to know.

Exceptional C++ (Herb Sutter) Presented as a set of puzzles, this has one of the best and thorough discussions of the proper resource management and exception safety in C++ through Resource Acquisition is Initialization (RAII) in addition to in-depth coverage of a variety of other topics including the pimpl idiom, name lookup, good class design, and the C++ memory model. [Review]

More Exceptional C++ (Herb Sutter) Covers additional exception safety topics not covered inExceptional C++, in addition to discussion of effective object oriented programming in C++ and correct use of the STL. [Review]

Exceptional C++ Style (Herb Sutter) Discusses generic programming, optimization, and resource management; this book also has an excellent exposition of how to write modular code in C++ by using nonmember functions and the single responsibility principle. [Review]

C++ Coding Standards (Herb Sutter and Andrei Alexandrescu) "Coding standards" here doesn't mean "how many spaces should I indent my code?" This book contains 101 best practices, idioms, and common pitfalls that can help you to write correct, understandable, and efficient C++ code.[Review]

C++ Templates: The Complete Guide (David Vandevoorde and Nicolai M. Josuttis) This is the book about templates as they existed before C++11. It covers everything from the very basics to some of the most advanced template metaprogramming and explains every detail of how templates work (both conceptually and at how they are implemented) and discusses many common pitfalls. Has excellent summaries of the One Definition Rule (ODR) and overload resolution in the appendices. Asecond edition is scheduled for 2015. [Review]

高级C++程序员

Modern C++ Design (Andrei Alexandrescu) A groundbreaking book on advanced generic programming techniques. Introduces policy-based design, type lists, and fundamental generic programming idioms then explains how many useful design patterns (including small object allocators, functors, factories, visitors, and multimethods) can be implemented efficiently, modularly, and cleanly using generic programming. [Review]

C++ Template Metaprogramming (David Abrahams and Aleksey Gurtovoy)

C++ Concurrency In Action (Anthony Williams) A book covering C++11 concurrency support including the thread library, the atomics library, the C++ memory model, locks and mutexes, as well as issues of designing and debugging multithreaded applications.

Advanced C++ Metaprogramming (Davide Di Gennaro) A pre-C++11 manual of TMP techniques, focused more on practice than theory. There are a ton of snippets in this book, some of which are made obsolete by typetraits, but the techniques, are nonetheless, useful to know. If you can put up with the quirky formatting/editing, it is easier to read than Alexandrescu, and arguably, more rewarding. For more experienced developers, there is a good chance that you may pick up something about a dark corner of C++ (a quirk) that usually only comes about through extensive experience.

骨灰级C++程序员

The Design and Evolution of C++ (Bjarne Stroustrup) If you want to know why the language is the way it is, this book is where you find answers. This covers everything before the standardization of C++.

Ruminations on C++ - (Andrew Koenig and Barbara Moo) [Review]

Advanced C++ Programming Styles and Idioms (James Coplien) A predecessor of the pattern movement, it describes many C++-specific "idioms". It's certainly a very good book and still worth a read if you can spare the time, but quite old and not up-to-date with current C++.

Large Scale C++ Software Design (John Lakos) Lakos explains techniques to manage very big C++ software projects. Certainly a good read, if it only was up to date. It was written long before C++98, and misses on many features (e.g. namespaces) important for large scale projects. If you need to work in a big C++ software project, you might want to read it, although you need to take more than a grain of salt with it. There's been the rumor that Lakos is writing an up-to-date edition of the book for years.

Inside the C++ Object Model (Stanley Lippman) If you want to know how virtual member functions are commonly implemented and how base objects are commonly laid out in memory in a multi-inheritance scenario, and how all this affects performance, this is where you will find thorough discussions of such topics.

=========================================================== from stackoverflow : The Definitive C++ Book Guide and List2014-06-24

谷歌工程师对C++的掌握有两个级别:

1. 拥有C++的readability(可读性)认证。通过这个认证需要在实际工作中写出一个比较复杂的完整的类,然后将这个类提交到一个委员会进行审查,委员会会帮你纠正常见的错误,如果你的这个类满足style guide[1]的所有要求,一两个星期之后你就可以拿到可读性认证。一般来说,你需要在实际工作中写过至少 几千行代码 才能达到这个要求。C++的readability对工程师的意义主要有两个,一个是熟悉并避免C++的缺陷(比如不要使用iostream和exception),另一个是熟悉一些常用的库函数(比如string的各种操作,hash_map和smart pointer的使用等)。通过这个认证之后,工程师就有权利在code review中审阅其他人写的C++程序(注意这个不是readability review)。绝大多数工程师对C++的掌握处在这个水平。

2. 顾问级C++程序员。一般需要写过 数万行 C++代码,用C++实现过比较复杂的系统,熟悉常见的设计模式并在实际工作中应用,对代码重构有丰富经验,最重要的是,成为小组以及周围同事的C++顾问,是同事有C++使用问题时最先想到询问的人。顾问级C++程序员通常是高级工程师(senior engineer)及以上级别,不仅对某种程序语言,对工作中的各种工程问题也经验丰富。

其实“精通C++”并不仅仅是熟悉C++本身,你需要对C++需要实现的工程问题和周边问题同样精通;而且“精通C++”这种说法是相对的,如果你能成为组里的C++顾问,能够帮助同事正确使用这种语言有效率地解决工程问题并避免C++的误区,你就算是精通C++的那个人。

摘自: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
面试时python,ruby是否比c++,java更有优势
Having interviewed a few hundred candidates across Google, Ooyala, and Quora, I would contend that the situation is quite the opposite, particularly if you're interviewing at the faster-moving end of companies like the typical startup.  The choice of programming language matters, and most candidates I've interviewed who can only code in C, C++, or Java put themselves at a competitive disadvantage relative to those who use Ruby or Python.

In an engineering interview, you typically only have thirty minutes to an hour to impress your interviewer and to demonstrate that you can solve technical problems and get things done quickly.  The faster you can complete a problem correctly, the more quickly I, as an interviewer, can move onto harder problems or assess your other skills.

Your choice of programming language is therefore important to the extent that it affects the speed with which you can solve problems.  Languages like C, C++, or Java tend to be significantly more verbose than more productive languages like Python or Ruby that come with more powerful built-in primitives like list comprehensions, functional arguments, destructuring assignment, etc.

Research by Prechelt that compared 80 implementations of the same set of requirements across 7 different languages showed that solutions written in C, C++, and Java were on average 2-3x longer in terms of non-comment lines of code than scripting languages like Python.  [1]  Paul Graham has also written extensively that one of the competitive advantages of his Viaweb startup was a more powerful and productive programming language.  [2]

The research lines up with my personal interview experiences, and I'd estimate that it takes the typical candidate roughly 3 times longer to express the same algorithm on the board in a non-scripting language than it does in a scripting language.  In interviews where a candidate actually needs to write executable code on a computer, the time that a person spends compiling C, C++, or Java code is time that another candidate who's proficient at Python or Ruby is using to address the actual problem itself. Once you factor in the additional time needed to recover from mistakes or bugs, the absolute time differences start to compound.  Each minute spent writing boilerplate code or additional syntax for a less productive language is a minute not spent tackling the meatier aspects of a problem.

The ability to choose the right tool for the job is an important skill.  Choosing a less productive language makes me wonder as an interviewer whether you'd choose less productive tools on the job, like trying to write C++ or Java code to parse and format files when someone can be orders of magnitude faster using shell scripts or a scripting language.

There are two exceptions I would make for candidates that use C, C++, or Java on a problem that could be more quickly solved with a language like Ruby or Python:

  • If you're a fresh college grad who hasn't picked up a scripting language, I tend to be more lenient and evaluate whether I think you can pick one up quickly on the job.

  • If you're more experienced, really proficient at C, C++, or Java, and can solve a problem as quickly as a good programmer who uses Python or Ruby, then that's a strong a skill to have, and I'll take into account that it'd probably be easy for you to pick up a scripting language.  Still, there would be a lingering doubt in my mind wondering why you didn't learn a more productive language over the years, since you would've been able to solve the problem that much more quickly.


All that said, there are probably certain interview situations where using a non-scripting language might be desirable.  If you're interviewing for a search company or a company that focuses on iOS or Android development, using C++, Objective-C, Java, or whatever the core language is at the company would certainly help demonstrate that you could be effective on the job quickly. If you don't know a scripting language well, it's better to use a language you're proficient at, though it'd be even better to just get proficient at a scripting language.  Ultimately, you want to pick the programming language that most effectively demonstrates that you'd be productive.  My advice would be to ask your interviewer if he or she has a preference, and if not, to choose the most productive programming language for the problem.


following things should suffice:

1) what is oops ?
2) can you explain to a layman with out using any technical terms what oops is?
3) what is function over loading, how did it make the lives of C++ programmer better than C programmer ?
4) How is function over loading achieved ?
5) what is dynamic binding ?
6) what is an abstract class ?
7) what happens under the hood for virtual functions ? (vptr, vtable etc)
8) what is diamond problem ? ( multiple / virtual inheritance )
9) why would you choose C++ over C ?
10) what is operator over loading ?
11) what is a namespace ?
12) How many kinds of castings are available in C++, how is it better than C ?
13) when and why will you use static functions in a class ?
14) do you have an idea what STL is ?
15) do you have an idea what meta programming is ? and how is it achieved in C++ ?
16) How are errors handled in C++ as opposed to C ? (exception handling)


bonus topics:
1) do you know any design patterns ? - (Factory, Singleton)
2) do you know any containers ? - (Vector, List, Map)
3) competition between function over loading and function over riding.

 if you can answer all the above questions you can rate yourselves 6.5 / 10, if you can code all the above topics then you can rate yourselves, as a collage graduate,  8/10.

 once you are comfortable with above topics, go read C++ FAQ's by marshall and claine.


C++ is a Huuuuuge Language .

The Path towards Expertise would be:
  • Understanding C++ - Step 0

You have got to read The C++ Programming Language by Stroustrup, no way you can escape this. http://www.amazon.com/The-Progra...
   
  • Understanding Histrory of C++ and Why come they designed the C++ Features - Step 1

The Design and Evolution of C++ Book from Stroustrup would help you. http://www.amazon.com/The-Design...

  • Understanding Internals whats happening when you declare classes. - Step 2

Inside C++ Object Model by Stanley Lippman would help you. http://www.amazon.com/Inside-Obj...

  • How to write Efficient Programs in C++ - Step 3

Agner Fog Optimization Manuals would give you Start. http://www.agner.org/optimize/  

  • How to write Correct C++ Programs - Step 4

Effective and More Effective C++ book would help, you cannot clear any C++ technical Interview without reading this. Better search for Scott Meyers in Google and Read Everything. He has huge insights for writing correct way of C++
  1. http://www.amazon.com/Effective-...

  2. http://www.amazon.com/More-Effec...

       
  • Understanding Design Patterns - Step 5

It would give basics to understand Huge C++ framework libraries such as Qt , Boost etc., The Gang of 4 Book would help you. http://www.amazon.com/Design-Pat...

  • Understanding How to Create Efficient Frameworks - Step 6

API Design by Martin Reddy would give you a start. http://www.amazon.com/API-Design...


Phew .... We came so far without even touching Meta Programming and Templates.


  • Meta Programming and Templates - Step 7



  1. Understanding C++ Templates would help. http://www.amazon.com/C-Template...

  2. Modern C++ Techniques from  Andrei Alexandrescu  would give you a start. http://www.amazon.com/Modern-Des...

  3. Another good stuff from Andrei Alexandrescu http://www.amazon.com/Elements-P...

  4. Knowing how to use STL also helps, The C++ Standard Library. http://www.amazon.com/The-Standa...


  • Understanding How to become proficient in MetaProgramming - Step 8

For this you need to take different path instead of learning C++ , you would learn Haskell or CommonLisp. Haskell would be perfect. http://bartoszmilewski.com/2009/...
But i took the other one (Common Lisp). http://letoverlambda.com/

  • Now its time to lose focus on C++  and Learn Compilers, Functional programming, meta programming etc..

  • Implement C++ Compiler. (no mere souls  done that if you can pull off you got big future in Google,Facebook etc..)


You may notice from Step 8, it become vague path. So I would say after Step 8 you need to invent your own Path.

  • Updating your knowledge to  C++11

A quote from Bjarne Stroustrup,

"Surprisingly, C++11 feels like a new language: The pieces just fit  together better than they used to and I find a higher-level style of  programming more natural than before and as efficient as ever.”  


 1. Just small introduction to what is C++11 ( A Tour of C++ (C++ In-Depth Series): Bjarne Stroustrup: 9780321958310: Amazon.com: Books ) ( C++11: A cheat sheet-Alex Sinyakov ) ...

  2. Getting deep understanding of C++11 ( New testament of The Bjble The C++ Programming Language, 4th Edition: Bjarne Stroustrup: 9780321563842: Amazon.com: Books )

 3. Using STL the C++11 Way ( The C++ Standard Library: A Tutorial and Reference (2nd Edition): Nicolai M. Josuttis: 9780321623218: Amazon.com: Books )

4. Concurrency the C++11 Way ( C++ Concurrency in Action: Practical Multithreading: Anthony Williams: 9781933988771: Amazon.com: Books )

For Reference ( Information technology -- Programming languages -- C++ ).

oh god So much to read but life is too short .

So my opinion would be C++ language is gonna stay here for foreseeable future unless we work on computer which is not based on Von neumann architecture.
So better invest your 10 years to expertise C++  and Computer programming.



你可能感兴趣的:(如何精通C++ 摘自知乎和quora)