Which websites should I use to learn C++? I also made it clear about the hole I stepped in
Once I was chatting with a friend who wanted to change careers. He said that he searched for C++ tutorials online and found hundreds of them. I didn't know where to start, but in the end, he simply didn't open any of them.
I completely understand the feeling. C++ itself is already difficult enough, and choosing a learning resource requires a lot of anxiety, and it is really discouraged.
So I wrote this. It's not the "Top Ten Authoritative Recommendations", it's just saying what you have used and not saying what you haven't used. Some of these I still use now, and some have been replaced after helping me get through a certain stage. That's all.
But before talking about websites, there is one thing to talk about first.
The biggest fear of learning C++ is not difficulty, but chaos.
I have seen too many people look for "C++ Advanced Tutorial" as soon as they come forward, but they give up after just two days of template metaprogramming. The order is wrong, and the more you learn, the more confused you become. This has nothing to do with talent.
A more reliable approach is this:
First the basics of syntax, then object-oriented, then STL, then data structures and algorithms, and finally system programming and deeper language features.
It's that simple. Don't recite it, but don't reverse the general order. Walking backward before the foundation is laid is equivalent to pouring concrete up before the foundation is dry-the more you learn later, the more it will collapse.
As for how long it takes to learn... I don't want to give you a false promise of "mastering in 10 months." This promise will be clear to everyone. Everyone has a different background and a different amount of time they can devote every day. I only give you a rough reference: If you can spend two or three hours a day, you can go from zero to find a job, for half a year to a year. It might be faster if students study all day long. Continuous advancement is more important than anything else.
These websites are the ones I have actually used
There is no ranking, classified by suitable scenarios.
If you are pure white, start with the rookie tutorial
Newbie tutorials are particularly suitable for zero-foundation courses-not because they are the best, but because they are the least likely to dissuade you. The interface is simple and the content is direct. There is an online editor that can directly run code without installing any environment.
When I first started learning it myself, I went through the basic grammar in a rookie tutorial. I didn't want to understand it all, but I first got familiar with it. This process of "getting acquainted with each other" is actually quite important. Once you have a basic sense of language, it will be less painful to read thick books.
The shortcomings are also obvious: the depth is really limited, the pointers are relatively shallow, and the object-oriented part stops. So you can start with it, but don't expect to rely on it to get to the end.
If you want to understand a language thoroughly, you can't avoid C++ Primer
Strictly speaking, this is not a website, it is a book-the fifth edition of "C++ Primer" with a blue cover. The Chinese translation costs tens of yuan.
The first time I read it, I felt like I had been "beaten back to my original shape." It turned out that what I thought I understood before was actually wrong. The good thing about it is that every concept is broken apart and it is explained very accurately. Many online tutorials have been simplified a lot in order to be "easy to understand", but some of the simplifications have actually gone astray. After reading this book, you will have an overall and accurate understanding of the language C++.
Don't read it from scratch as a novel. Do a large number of exercises every time you read a chapter, and use them to test whether you have really absorbed it.
When you can't read the text, go to Station B to watch Shangsi Valley
Some things are abstract just by looking at the text. The object-oriented part was still blurred after reading the tutorial several times. Later, I went to Station B and found Shang Silicon Valley's C++ video. After listening to it, it suddenly worked.
This tutorial is free and covers everything from variable definition to actual project practice. The quality is very high among the free videos I have seen.
But there is a trap in watching videos-"If you understand it, you will learn it." Let me tell you, the distance between understanding and writing is the distance between how many lines of code you should type. Do it after reading it, don't be lazy.
Daily development check data and directly collect cpreference
Strictly speaking, this is not a tutorial, but an official reference document for the C++ standard library. But it is a standard bookmark for all C++ developers.
When learning C++, you will encounter countless questions such as "How to use this function?" and "What is the complexity of this container?" Go search blogs? Check Stack Overflow? It's better to check this directly. It is the most authoritative and updated in a timely manner.
Beginners may find it too dry and unhuman. But it is never too late to develop the habit of "checking documents if you are not sure" from the first day.
Looking for a job? Brush LeetCode
Algorithm questions are almost mandatory for interviews with large domestic factories, and many people use C++ to brush them. If your goal is to find a job, there is no escape.
I have my own opinion on brushing questions. Many people chase the number and say they have to brush 300 or 500 questions. But I think quality is more important than quantity. You can do a medium question yourself, which is much more effective than looking at the answers and "understanding" the ten questions. The quality of the Likou problem solving area is generally good, and it is also good to see other people's ideas after finishing it.
There are no shortcuts, just one way at a time. It is normal for a certain question to be stuck for two or three days. After you break through, you will have a significant improvement.
GitHub is not just a place to store code
After having a certain foundation, reading excellent C++ source code has a greater effect on improving coding levels than reading any tutorial.
There are several projects that I think are worth watching that I have screened:
C++ Things-A Chinese C++ learning guide warehouse, which collates the learning route and interview key points, suitable for sorting out the knowledge system after getting started.
TinyWebServer--a high-performance Web Server written in C++. The amount of code is small and the core concepts of back-end development are basically covered. It is very suitable for learning.
muduo--the network library written by Chen Shuo. It will be very smooth to read together with his "Linux Multithreaded Server Programming".
There are thresholds for source codes, and it is not suitable for novices to work on big projects as soon as they come up. Look at the small ones with clear structures first, and then touch large projects when you have a feeling.
If you encounter problems writing code, go to Stack Overflow to find answers
There should be no need to introduce this. When writing C++ programs, there is a high probability that someone on Stack Overflow has already stepped on the same pit.
But it's not just an "answer search" tool. There are many high-quality discussions above, and many of the answers are written by big names in the C++ field. Their explanations are sometimes clearer than textbooks. Sometimes I go through some high-profile answers on C++ topics when I have nothing to do, and I can often learn unexpected things.
One tip: The way you ask questions is important. Questions that are clearly described and include minimum reproducible code are much more likely to be answered than simply posting a paragraph to report errors.
Geek time can be considered in the advanced stage
If you have some actual C++ development experience and want to go deeper, there are several columns in Geek Time that can do it.
Wu Yongwei's "C++ Practical Expert Lesson" goes in depth and will explain some things that you may have been confused by from the perspective of language design. Wang Zheng's "The Beauty of Design Patterns" is not exclusive to C++, but the design pattern area is something that cannot be avoided when doing C++ development.
I want to say something not very nice here: Think carefully before buying a paid column. After reading free resources, you really need to go deeper and buy them. Don't spend them impulsively at the beginning. Many people don't finish reading it after buying it, wasting money and creating anxiety for themselves.
Focus on using Niuke. com during job search
If the goal is to find a job in C++ development, Niuke. com is an indispensable platform in China. A large number of real company written test questions and face-to-face interviews are very targeted.
But just use it intensively during the preparation stage of the interview, and don't always brush up on special exercises on it. What you practice by brushing questions is the ability to test. What really determines whether you can pass the interview is your depth of understanding of the C++ language and computer basics. Daily accumulation is much more important than temporary crafting.
If your English is okay, LearnCpp.com is a good choice
If you can speak English well, this website is very systematic and of high quality, starting from the most basic concepts to modern C++ features. It has been updated and maintained, and the novelty of C++17/20 is also involved.
Its writing style is hands-on, with practice questions and answers at the end of each chapter. Among the English tutorials I have read, this is the most friendly to beginners.
Tell me some really useful learning methods
The websites recommended above each have their own focus, but there are actually only a few core methods for learning C++:
Write code, write a lot of code. It is better to read the tutorial ten times than write it yourself. Even the simplest Hello World has only really been run when you type it out yourself.
When encountering bugs, debug them yourself first. It is impossible to write C++ programs without bugs. Spend your own time analyzing first, using the debugger and print logs to locate. This process is painful but it grows fastest. I really couldn't go and ask someone again.
Start projects as early as possible. Learning grammar alone is boring and easy to forget. Once you have a certain foundation, find a project to do-it can be widgets, Mini games, or rewriting TinyWebServer. When doing a project, you will find a lot of things that you think you understand but don't. This is the time to truly make progress.
Don't read too much information at once. This is the biggest hole I have ever stepped on. If you read too much information, you will have the illusion that "I have learned a lot", but I have not learned every book thoroughly. Choose a main resource and follow it carefully, and refer to others when you have the strength to do so.
Isn't C++ worth learning?
People often ask me this question. My answer has always been: It depends on what direction you want to go.
Operating systems, game engines, high-performance services, embedded systems, autonomous driving-these areas have extremely high performance requirements, and nothing else can replace C++ in the short term. If you want to move in these directions, C++ is worth investing in.
But if you just want to find a job and have no special interest in system-level development, then the entry threshold for Python, Go, and Java is much lower and the employment range is wider. It's not that they are better or worse, it's just that there are different suitable options for different scenarios.
One more thing I think is worth saying: the process of learning C++ itself will allow you to establish a deeper understanding of the underlying computer. Concepts such as pointers, memory management, and compilation links will have a different feeling when you look at other languages after learning C++. In the future, you will not mainly write code in C++, and this experience will not be wasted.
A few last words
Learning C++ is a long way, and there will definitely be times when you want to give up. I almost gave up twice back then-once when learning pointers and memory management, and once when reading the STL source code. Every time, I would bite through it and find that it was not as difficult as I thought.
There is no secret, which is probably: Don't compete with others for speed, don't pursue a perfect understanding of every detail, and don't be afraid to write bad code. The code is changed, and the ability is accumulated step by step.
It's good to start, but it's better to start.
If you are learning C++ or plan to start, I hope it will help you avoid detours.