How to Learn C ++ language well

Source: Internet
Author: User

Original article: http://coolshell.cn/articles/4119.html
Author: Chen Hao

I wrote an article about how to learn C language well yesterday and someone asked me how to learn C ++ well. So I wrote some of my learning experience here, hoping to help you. First, we will only talk about C ++ because we have learned about algorithms and systems in C language.

  • C ++ is the most difficult language. The most difficult programming language in the world may not belong to C ++. Do not think that the learning curves of C ++ and C ++ can be quite Bt in a few days. You can read this article. C ++ is a very free language, and it is a bit Bt and scary. I even think C ++ is not a mature programming language, because it is too easy to make mistakes. So,You must have a very cautious attitude at the beginning, and treat c ++ as a tough beast..
  • Ask the question "Why ?". When learning C ++, you must ask the following questions: "Why is this?" and "why. For example, many people know that C ++ has a copy constructor and an initialization list, but do you know why copy constructor is required? Why is there an initialization list? Why is there a template and rtti? Why not? Is it to make a language cool? This is not the case at all. Any feature in C ++ has some real reasons,You must understand why C ++ should be designed so that you can learn C ++ well.. Take a look at C ++ evolution and design.

  • Reading books, a large number of C ++ books. You can read these books in the order below (it took me about 4-5 years and I am still reviewing them today)

    • C ++ primer, this preliminary reading may make you suffer, and read the features and why of all languages. Of course, the C ++ programming language written by the father of C ++ is also good. Just read one of the two books (I am reading the former ).
    • Understanding the syntax of C ++ is only the first step in the long journey. You also need to take a look at Objective C ++ and more
      The two books of Objective C ++ are not very thick, but I have been seeing them since 02 years ago. Every time I read them, I have a new experience. These two books are too classic. If you are not familiar with the C language, these two books will let you go back to the C language class.
    • Think in C ++ is also another classic book. It is required to learn C ++, but the translation of the Chinese version is not good. So read the English version.
    • "C ++ meditation" is also worth reading. It is very precious to teach not programming but thinking.
    • Predictional C ++ and more
      Predictional C ++ shows you how to solve various problems and some common classic errors.
    • Advanced C ++ and modern
      C ++ lets you know the magical usage of C ++.
    • Generic programming and STL is something that puts C ++ into practice. Very powerful. STL-a god-like Template Library (containers, algorithms, and function objects.
    • In-depth exploration of the C ++ object model allows you to understand what C ++ is under the compiler, and the performance of C ++ is not bad. This is too critical for C ++ programmers. I have previously written "C ++ virtual function table Parsing" and "c ++ Object Memory layout" in this category.
  • Comparison with Java. I personally think Java has made a lot of adjustments, specifications, and restrictions on the immature C ++ language. So, let's compare Java and C ++ and think about why some things can be done in C ++, but not in Java. For example, a Java exception must be caught. Otherwise, the compilation fails. Why does Java not provide Operator Overloading? Why does Java introduce interfaces for multi-inheritance? Why is there no I/O compaction stream like C ++ in Java? Why does Java not support pointers? Why can Java achieve garbage collection? And so on.Java embodies a lot of object-oriented design things. Learning Java helps you learn how to better use C ++ for programming..
  • Object-Oriented Design. Although object-oriented may be a scam. However, I think some practices in object-oriented design are very good, such as the single principle and dependency inversion principle. Design patterns must be read, and object-oriented analysis and design can be read.However, the design mode cannot be centered for programming, but the design mode should be used to solve the problem..
  • Class Library Learning. Let's take a look at how MFC encapsulates windows APIs, How ace is object-oriented, how boost is object-oriented, and how cppunit is designed. Of course, there are too many design patterns in Java JDK. For details, refer.

I hope it will not scare you, and you are welcome to add it.

----- Update 2011/03/30 19:20 ----

Update several points of view:

  • 1) I am not good at writing book reviews, so the recommended books may make you feel a little confused. You can go to Douban or China-pub to check the book reviews.
  • 2) C ++ has many odd tricks, some of which are BT, including virtual function tables. Some may think it is boring, but I think it is interesting, on the one hand, you can understand the implementation details of a language, and on the other hand, you can broaden your thinking. I have benefited a lot from learning this knowledge.
  • 3) The above is my personal learning experience. I think it is very effective for me.
  • 4) There are many and many such articles on the Internet. I am not the first to write such an article, nor do I write the best. I don't want to talk about it in a long article. I just want to show you the approximate learning style. After all, C ++ is profound and profound, and cannot be said in any article. It is easier.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.