Some thoughts on C++ (excerpted from How to Learn C++ Language Well)

  • Ask more “why is this happening?” questions . When learning C++, you must ask more questions such as "Why is this?" and "Why should it be like this?" For example: Many people know that C++ has a copy constructor and an initialization list, but do you really know why there is a copy constructor? Why do we need an initialization list? Why do we need template, why do we need RTTI, why not something else? Is it just to make a language cooler? This is not the case at all. Every feature in C++ has some real reasons. You must understand why C++ is designed like this, so that you can learn C++ well. Read the book "C++ Evolution and Design" when you have time.
  • Read a lot of C++ books .
  • Compare with Java language . Java has made many adjustments, specifications and restrictions to C++, an immature language. So, compare Java and C++ and think about why some things can be done in C++ but not in Java. For example: Java exceptions must be caught, otherwise the compilation will fail. Why doesn't Java provide operator overloading? Why does Java introduce interfaces for multiple inheritance? Why doesn't Java have an I/O character stream like C++? Why doesn't Java support pointers? Why can Java do garbage collection? etc. Java embodies many things in object-oriented design. Learning Java will help you learn how to better use C++ to program.
  • Object-oriented design . Programming cannot be centered on design patterns, but should be decoupled using design patterns.
  • Class library learning . Look at how MFC encapsulates Windows API, look at how ACE is object-oriented, look at how boost is object-oriented, look at how CPPUnit is designed, there are too many design patterns in Java's JDK , you can refer to.

Original text: How to learn C++ language well by Chen Hao CoolShell

Guess you like

Origin blog.csdn.net/gaochubusheng/article/details/131713790