How to Learn C ++

Source: Internet
Author: User

From: http://www.perfect-is-shit.com/2012/12/11/how-to-learn-cpp/

Thank you for your summary.

About this article

  1. Readers are positioned in two categories:. beginners are about to start with the c ++ language and do not know how to start. B. I have been learning C ++ for a long time, but the progress is slow. I am confused because I cannot grasp the essence.
  2. This article will not go deep into the internal mining technical points of the C ++ language.
  3. If you are a C ++ expert, bypass it. If you are a C ++ expert and have rich development experience, you can provide some suggestions for this article.
  4. Based on my own learning experience and experience, this article will talk about how to learn C ++ and some ideas and opinions on extending it to the programming field.
  5. This document does not comment on books. I have listed some C ++ books in my book recommendations, all of which have my related comments. If you are interested, you can take a look.


Body

Why C/C ++?

C ++ is a programming language. Note that it is only a programming language. This sentence means that once someone is in the competition for good or bad language, they just smile. A specific language is only used to solve specific problems in a specific field. the correctness of this sentence is unquestionable, especially in the age of numerous languages.

In the field of programming, everyone has his/her own introductory language. I personally think that C language is a very good choice. It has simple syntax, deep but shortest depth, and the originator of advanced languages. It is very important that today's various programming languages are more or less derivatives of C language, or derivatives of derivatives. It is difficult to get started with other languages as long as C linguistics is good. The soul of C language lies in pointers, which can help you better understand the memory and operating system.

C ++ is one of C's derivatives and is compatible with C language. The initial goal was to expand the C language "C with classes", but with the development, the C ++ standard added virtual functions and operator overloading) multiple inheritance, template, exception, rtti, and namespace. C ++ becomes more powerful and more complex. With the increase of new content, C ++ is farther and farther away from C (ideology rather than syntax ).

C ++ is a controversial language. There are many people who like to study it, and many others (including some famous people. In the era of C/C ++ (when C/C ++ was just getting out of the road), there were few optional languages. Therefore, C ++ has done a lot of things. Now the times are different, just as many languages have been called before, there are a lot of targeted languages, and there are more choices for programmers (there are a lot of excellent languages to learn, C #, Java, PHP, Python, ruby ......), Therefore, C ++ is no longer a luxury product.

Before you start learning, consider carefully. Why? If you have considered it, continue reading it.

C ++ beginners choose a good book

If you find a book named "Number", Please discard it! (21 days to learn C ++ ?)
If you find a book named after "tong", Please discard it! (C ++? C ++ from getting started to proficient ?)
If you find the C ++ tutorial that links "visual" and "c ++", Please discard it! (Too many, no example)
If you find "Void main" as an instance book, Please discard it!
If you find "" as an instance book, Please discard it!
......

There are several books for you to choose from: C ++ primer plus, C ++ primer, and C ++ Programming Language

I used "C ++ getting started classic", followed by "C ++ primer". In fact, it is easy to distinguish between good books and poor books. Thickness and price are a key point. They are usually thin and cheap, but the title of the book is very domineering and tells you how to be proficient, then, you can't think about it.

Select a good ide

Please note that I emphasize IDE (integrated development environment), rather than the package (GCC + Vim/Emacs + GDB + [Linux]). For Beginners, you must focus on it.

What is the Nb package? NB! Cool? So cool! Learning? Yes, but not now. Now you need to enter a few lines of code and then run the results. If there is a small problem, you can easily debug the tool. GCC, VIM/Emacs, GDB, and Linux must admit that they are excellent, but it takes time to learn well. It is no exaggeration to say that starting with vim/Emacs or Linux is much more time than starting with C ++. Beginners must believe this. Too many people on the internet boast that C ++ should not use IDE, so they should directly use the text editor + GCC to debug with GDB to despise IDE. I don't know what kind of mentality you are holding. I just want to say that you are getting started like that? Were there any
IDE? Do you know about ide? What development does your company use?

The underlying debugging tool called by IDE is also a debugging tool that encapsulates the debugging tool to make it more user-friendly. Technology is never used to cool and install B, but to solve practical problems. Therefore, no matter what language, tool, or platform you use, you only need to do things well.

For a beginner, a user-friendly debugging environment is required. Of course, as a C ++ programmer, GCC/GDB must be understood, and Linux must also be met.

Ide I recommend codeblocks, which is well supported by the C ++ standard, open-source, cross-platform, free, and excellent. Microsoft Visual Studio 20XX is also supported. Advice: you should never use VC ++ 6.0 again. You have very poor support for the c ++ standard. Remember!

I have been learning to use codeblocks 10.05. Today it seems that it is already 12.11. Software Development uses vs2005, vs2008, and vs2010. I personally feel that 08 is not 05 or 10 easy to use.

Keep a calm mind

I will show you an article: "I will teach you how to C ++ in 21 days ". "To learn C ++ in 21 days, it would take 8 years to learn C ++ first, and then to learn quantum physics, biochemistry, molecular biology, and genetics, create a "returning to the old" potion and send yourself back to the 21 days of programming. This is the easiest one I know so far, "Teach Yourself C ++ in 21 days". we recommend that you read the original article.

Let's look at another article: "a graph of self-confidence of C ++ programmers". "For most programmers who claim to be familiar with C ++, basically, they all use C ++ syntax to write C."

It is very important to keep a calm mind. Remember not to rush for success or be impetuous. Learning C ++ is not a matter of three days or two days. As I mentioned in this article, I spent 10 years learning programming. Are you ready?

Some people naively thought that they could write software after learning C ++ for a few days. Later they found that they could not do anything after learning it. The software needed the interface, so they went to learn MFC, after learning MFC, I found that MFC has nothing to do with it. On the contrary, the C ++ foundation is too poor. Instead, I continue to learn C ++. The naive person is me, so I came here. Behind the high-end is nothing more than a line of basic code. As long as the foundation is completed, the high-end will have nothing to do with (the high-end here is not specifically about the high-end MFC, the basics are not specifically C ++. I think everything is the same ). I would like to tell you that it is more useful to lay the foundation than to learn high-end technologies, so don't worry.

What else do I need?

I think it is enough. A good book, a good ide, and a calm mind (of course you need a PC ). There are three points that I need to explain. First, it doesn't matter if we choose the platform. c ++ is cross-platform, so we can learn the C ++ standard. Second, will training be faster? I only use two words for training to sum up "nonsense. Third, video learning? I do not recommend. It is like watching Sun Xin's video when many people learn MFC. We are not children anymore. Do we need hands-on skills to learn things? In addition, all things taught by hand are dead. When you hold a hammer in your hand, you will find that the world is full of nails. There are many ways to solve the problem. Video can teach you only one or more fixed ways, and the mindset is terrible.

I personally do not agree to spend money on training, or watch videos in front of a computer.

Learning is an experience, and this experience becomes your valuable experience. When you encounter problems, you are diligent in thinking and analyzing, reading materials, and gradually cultivate a set of methods to quickly and independently solve the problems. This is your fortune, and this will remain the same. For programmers, It is a keen sense of bug.

C ++ entry (stay on the surface)

Reference Standards: familiar with the c ++ syntax structure, understand the main modules and technical difficulties of C ++. Knowledge points that can be found in most books.

Do you want to learn C ++?

As such an article, this discussion is almost necessary. I have a clear idea. I want to learn it! Because I first learned the C language, followed by C ++, and learned from each other through numerous interactions. In my program, I have never deliberately determined whether it is C or C ++. The standard I grasp is how convenient it is. It seems that I have never used the file stream of C ++ to read and write files, because I am used to fread, fwrite, fopen, fseek, and ftell in C language. I want to learn from the perspective of language syntax and library. If you want to learn object-oriented, you don't have to learn C. It seems that you have no need to learn C ++, it is not better to select a pure object-oriented language to learn object-oriented language. Summary: Based on my personal experience
C ++ can learn the C language first (The point of view is clear and the discussion is over !).

What do you want to know? There are two points in summary: syntax and library. Almost all languages are the same.

  1. Syntax [basic type, standard library type, array and pointer, expression, statement, function, etc.]
  2. STL [container, algorithm]
  3. Templates and generic programming
  4. Class and object-oriented

It is essential to be proficient in syntax; to be proficient in STL programming, object-oriented thinking is not available in a day or two and can be cultivated only through continuous experience and practice; the implementation method of object-oriented in C ++ must be familiar with (inheritance, derivation, virtual functions, etc.); the real parameter deduction of the template should be clarified.

How to get started?
  • Read books. C ++ primer, C ++ standard library, and C ++ Template
  • Think more and write more small programs.
C ++ advanced (Technical Research)

Reference criteria: internal mechanism, odd sex skills

  1. Go deep into the C ++ and explore the implementation mechanism [Why does the template not support separate compilation? How is virtual functions/Multi-inheritance implemented? What type conversion does? Exception Handling? And so on]
  2. STL source code learning [learning others' design methods? Why is STL efficient )? Learning data structures and algorithms? Memory Pool? Rtti? And so on]
  3. Memory [understanding pointer operations? Memory alignment? Class memory layout? What is the difference between new/delete and malloc/delete? Implementation of function variable parameters? Storage method? Smart pointer? And so on]
  4. The compiler secretly did those things during compilation and linking. [How do I analyze the prompts of the compiler? What are the possible causes of Link errors? And so on]
  5. Keep up with the c ++ library trend and study new standards.
How to achieve advanced?
  1. Read books. Other Books, STL source code analysis, C ++ standard library, C ++ meditation, high quality C/C ++ programming, c ++ programming ideas, and in-depth exploration of C ++ object models.
  2. Write software. If you have any problems, you can make your own research.
  3. Visit the community to answer other people's questions.
  4. Look at other people's blogs.
  5. Create your own technical circles.
C ++ experts (coming out of c ++)

References: Object-oriented programming and generic programming

Face object and generic programming are the essence of C ++. It is not enough to learn these aspects well. Only a large number of practical practices can you understand their advantages.

Many people think that C ++ has learned a good job. In fact, he is only writing C ++ code in C mode. This sentence is not without reason.

How to become a master?
  • Read "Object-Oriented Analysis and Design", "design patterns-the basis for reusable object-oriented software", "Generic programming and STL", and "c ++ template metaprogramming.
  • "Practice-> perception-> Summary-> practice-> perception-> summary ......" This cycle
C ++ brain powder (looking back at C ++)

Reference criteria: Why c ++ is C ++

Understanding the history of C ++ and its philosophy. Why does C ++ include the current components, why is it so complicated, and why there are so many defects. In short, why C ++ has become C ++, rather than anything else? This is really a question worth thinking about.

How to become a brain powder?
  1. Read books. Design and evolution of c ++ Language
  2. Collect wild history.

Well, I have summarized this many points. I personally understand that the C ++ learning process should be like this. But it does not mean that you have become a master of all the books I listed. First, the books I listed are not comprehensive enough. Furthermore, the two words I repeatedly mentioned above are "practice", and the things in the books will always die, this knowledge can be integrated only through continuous practice.

Next, let's talk about C ++ learning. I like to talk about it. The above regular method is not what I am good at (what I am good at is idle ). The learning process of isolating C ++ is slow. Only by having an entire "Computer Knowledge System" in mind can we promote each other and make progress quickly.

What is a computer knowledge system?
  1. Operating System. This is the first computer course. No reason. You must learn well. Process Management? Memory Management? File Management? I/O communication?
  2. Computer composition principle. Integer addition, subtraction, multiplication, division? Floating point representation? ? Interrupt and DMA?
  3. Assembly language. It is not required to write, but it is enough to understand the disassembly of the Code.
  4. Data structures and algorithms. Do not explain.
  5. Compilation Principle. What is the impression of "parser-> semantic analyzer-> source code optimizer-> code generator-> target code optimizer?
  6. Computer network. TCP/IP?
  7. C Language

After reading these items, you may say, "well, isn't that the lesson I escaped ?", That's right. This is the lesson we escaped. It's really important. Don't ask for anything else. As long as you understand these courses, I dare say that most of your c ++'s problems about memory and compiler compilation links have been solved. And whether you are learning C ++ or other technologies, it's easy to understand. Because this is the foundation, you have finished the foundation, and you will never miss it.

The C ++ you are going to learn right now, you think you have learned very well, but you can give others two or three months of patience to learn, the same as you can learn, even better than you. So where do you learn the value? I have learned C ++ for several years. Can someone else learn it in just a few months? Yes. How many things do you think C ++ has ?! How can we make others surpass you?

  1. The architecture in your brain has been integrated with the c ++ you have learned. Classes in your brain are stored in memory, your recursion is to constantly press the stack in the stack, and all you see is the code. That's why I disagree with your training institution. The training institution will not teach you these major subjects. He will only tell you how C ++'s functions are declared and how classes are written. These 100 yuan have been spent on buying a book and reading it for a few days. Why spend so much money on training.
  2. Write more code and call more programs. Cultivate the ability to perceive errors.
  3. Learn to explore and think more.

If your c ++ just stays on the surface, it's better for others to learn it in three or two months.

A few years ago, when I was using csdn, Lao Zhao's sentence was very popular: "Computer composition principle → DOS command → assembly language → C language (excluding C ++) code writing specifications → data structure, compilation principle, operating system → computer network, database principle, regular expression → other languages (including c ++), architecture ......", It makes sense.

Let's look at the questions in this article: how to learn C ++. In fact, I don't want to focus on C ++. I want to discuss how to learn it. c ++ is just an example.

Nowadays, the Internet is impetuous. As a result, students are impetuous and want to step into the sky. The dirty learning environment is that I want to earn a few clicks, just like the verbal war on the homepage of the blog garden. You can spray me, I can spray you, in fact, at the end of the day, I don't know what everyone is spraying. I only know that I have to stand up and spray it to prove my existence! This is a miserable environment. How many times does it take to write technical articles? New technologies are emerging in an endless stream, dazzled, and do not know what to do. Some people say yes, but they must be sprayed. As a newbie, how do you choose? I began to rejoice in my ignorance and ignorance gave me fewer choices. As a bystander, I do not have much to do. I dare not go deep into it. I can only stand far from shouting.

"I suggest you learn those major subjects well, C language well, and then select other programming languages. ."

Finally, let's give you some advice to end this article:

  1. Multi-Communication: no matter how hard your technology is, you cannot do everything by yourself. You must learn to cooperate with others and communicate with others. Pay attention to communication skills during communication. Learn to respect others, but be humble.
  2. More hands-on: Practice makes perfect. This is a panacea. What we do is technical work. What best proves our abilities is doing it! Not nonsense!
  3. Think more: Do not encode the machine.
  4. Conclusion: The same problem cannot occur only once, especially in our industry. The conclusion is that you can solve similar problems faster and improve work efficiency in the future.
  5. Share more: share more, you will get more, believe me.
  6. Read more: Listen more: not limited to technology. You need to understand more than technology. If you have the same question, you will get more information about what others think and how they think.
  7. Never take it with others: No one is obligated to help you solve the problem. Don't open your mouth and give it to you. It's lucky to give it to you.

There are a lot more to talk about. Let the blog wait ......

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.