Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the difference between C language and C++ language?
What is the difference between C language and C++ language?
The difference between c and C++:

C is a structured language, focusing on algorithms and data structures. The first consideration of C programming is how to operate the input (or environmental conditions) and get the output (or realize the process (transaction) control) through a process.

C++, the first consideration is how to construct an object model, so that this model can fit the corresponding problem domain, so as to obtain the output or realize the process (transaction) control by obtaining the state information of the object. So the biggest difference between C and C++ lies in their different ways of thinking to solve problems. C++ is superior to C because "the concept of design has been integrated into C++".

Let's analyze the difference between C++ and C step by step:

Class, class for beginners, is a burden. The encapsulation of classes makes beginners tired, uncomfortable and troublesome of programs.

Second, reference, reference is best not to be used in C++ unless absolutely necessary. References are confusing for beginners, and they don't know which is a reference and which is a variable.

Third, function overloading, it seems that there is no harm for beginners to learn function overloading, but it will make beginners subconsciously downplay the importance of variable types in C language. Remember that C language is the most sensitive to variable types, and the importance of variable types in C language is self-evident.

Fourth, the stream operator, like the above, downplays the importance of variable types, and sometimes produces confusing results for beginners.

Five, operator overloading, a typical advanced application, beginners may not use it at all, this thing will make them feel that C++ is difficult, the threshold is high, and they can't understand it.

Sixth, inheritance, as well as virtual function, looks abstruse and has low practical value. I won't comment on some others, such as: new, delete operator, etc.

Seven, misunderstanding: in the form of a question and answer:

Q: C++ is object-oriented and C is process-oriented?

A: The second question is wrong. C++ is not completely object-oriented. I'm afraid only Java can be regarded as a real object-oriented language.

Q: Can C++ achieve functions that C can't?

A: At least I haven't found it yet.

Q: Is there any obstacle to learning C++ after learning C? Such as programming ideas.

A: At least I have never seen anyone with this symptom.

Q: Do I have to start all over again after learning C++?

A: No, all the functions of C language can be realized under C++.

Q: Do you have to learn C++ to program after learning C?

A: It is totally unnecessary.

Q: What's better about C++ than C?

Answer: It is more in line with software engineering.

Q: Is it easy to learn C++ after learning C?

A: That depends on whether you have really finished learning C language.

The biggest difference between C and C++ lies in the different ways of thinking to solve problems. C++ is superior to C because "the concept of design has been integrated into C++", and as far as the language itself is concerned, C is more of an algorithm concept. It doesn't matter if it's a C. Wrong! Algorithm is the basis of programming, and good design can't be done without good algorithm. Moreover, "C+ good design" can also write very good things.

For the language itself, C is a subset of C++, so what kind of subset is it? As can be seen from the above, C has realized the process control and other related functions in C++, while C in C++ (I call it "C++") has been strengthened compared with the original C, introducing overloading, inline functions, exception handling, etc., and c++ has expanded the contents of object-oriented design, such as classes, inheritance, virtual functions, templates, container classes, etc. In addition, data encapsulation and types are nothing new in C++. What needs to be considered are the choice of object granularity, the design and inheritance of object interface, the use of combination and inheritance, and so on.

Therefore, compared with C, C++ contains a richer concept of "design", but C is a self-consistent subset of C++, which also has powerful functions and is worth learning.