One of the goals of C ++ is to provide more easy-to-use and affordable design ideas and program design technologies to further improve the quality of the program. Most of these technologies are sourced from Simula and are generally discussed as Object-Oriented Programming and object-oriented design ideas.
In the forum, beginners often ask "is it necessary to learn C before learning C ++ language ?". I think this is a pseudo problem. The answer to the question itself is not what the person who raises the question really wants. The answer to this question is very simple: "Of course not required ". Because C ++ is an independent programming language, it does not need to depend on any other language in terms of syntax, build environment, and run environment. It is a "hyperset of C language ".
That is just a fuzzy method. The more accurate statement should be: C ++ fully considers the compatibility with C language from the beginning of design, as a result, it is quite compatible with the C language. That's all. But for beginners who ask such questions, will the above be the answer they want? I don't think so. At least the problem is not that simple.
C ++ supports multiple programming paradigms: process-oriented, object-oriented, and model-oriented programming. It is compatible with the C part, which is also the main part that supports process-oriented. With the C language foundation, although it helps to grasp the process-oriented part of C ++ more quickly, the C ++ language itself also directly supports process-oriented, therefore, we can directly LEARN process-oriented programming from C ++ without having to learn C first. At least theoretically.
But let's talk about it again. Note that most of the questions are raised by beginners. Generally, the tutorials on C ++ language are limited by space. The process-oriented tutorials cannot be comparable to an excellent C language tutorial. As a result, the real question comes: For beginners who start learning from the C ++ language directly, Is he willing to spend as much time and effort as a beginner in the C language to study process-oriented programming?
If he doesn't want to, then his mastery of the process-oriented part will be difficult to compare with a person who has learned C language in a down-to-earth manner. Even if we only discuss "C in C ++", the same is true. However, Here I just want to emphasize this fact, rather than the conclusion that "C must be learned first.
When I was a beginner in the C ++ language, I felt that many things learned in the tutorial, including object-oriented programming, could not be used freely in practice. Later, due to work needs, I went to learn the Java language, and suddenly I had an open feeling about object-oriented. When I used C ++ to write a program, I found that OO became smoother, and several of my friends had similar feelings. The reason is that I want to keep up with the C language of the above analysis. C ++ supports more features and programming paradigms, making it difficult for beginners to quickly digest all of them. Before Java 1.4, it can be considered to be purely object-oriented.
In this way, when using Java to write programs, we are forced to practice object-oriented programming. This is like using C to write programs, and we are forced to practice process-oriented. Directly Using C ++ to write programs does not mean "forced", so we lack the corresponding "special intensive training ". Not all people need this kind of "special intensive training", but for beginners, it can indeed play a "divide and conquer" role in the face of the complex knowledge system to be mastered, this facilitates the digestion and absorption of knowledge.
Some people think that C ++ has naturally learned C. In my opinion, this is not a question. We must acknowledge two points: first, the C language is useful, so we don't need to say much about it. So many projects and complex systems built by the C language are there. Although it does not provide direct support for various more abstract programming paradigms, including object-oriented, it has long been proved to be able to solve complex problems. Second, the designers of C ++ language design a new language, not just a "better C ". This causes C ++ to inherit the C language and discard all its features.
- Reference functions and variables in C ++ in C
- Advanced technical scholars compile C ++ code
- Detailed description of C ++ compilation and code Problems
- Describes various programming skills of C ++.
- How to Learn and explore issues when using C ++ Builder
As a result, there are many such situations: a feature is very important in C language, but C ++ has some new features to replace it, and may do better. In this way, some features in the original C language are not mentioned in the C ++ language although they are still compatible, but are greatly reduced or not promoted.
There are many examples in this regard, such as "macro", and there are too many things in C ++ that can replace Macros in various occasions; and then variable parameters, there are also some complex usage of pointers. These things are very important in the C language. It is important to become one of the direct reasons why the C language is "useful. For these reasons, a person who is familiar with the C ++ language and has never studied the C language independently will be asked to take charge of a C language project one day, I don't think he can do it easily. Therefore, I believe that the idea of "learning C ++ naturally learns C" is unreasonable.
Some people have said that "the C language is a structured assembly", and that's right, its functions, efficiency, and portability have all achieved its original design intention, it also has a unique solution to various problems in real projects, but the same solution may not be appropriate in C ++, and vice versa ). In other words, from the perspective of solving the actual problem, no one is included in these two languages. But aren't we learning program design to solve practical problems? The conclusion has come out: the syntax of C ++ almost completely includes C, which does not mean that C is actually included.