Java language and C ++ language difference - old life talk

zhaozj2021-02-17  31

[Declaration] If you need to copy, spread, please attach this statement, thank you. Original source: http://morningspace.51.net/ ,moyingzz@etang.com [引子] This topic is not fresh, but as a class of language comparative classes, compared from the foundation, specific, detail level, To make a summary, I am afraid that Beginner should be beneficial. I want to come to the saliva, or conceptual, and the big-level comparison is more actually some of the syntax format of C and C . For program designers who have learned C and C , learning Java will be relaxed. However, if you carefully check many of the details of the Java language, you will find that Java has canceled the characteristics of many C and C , and some new features are added. These differences include: o no longer has a pointer concept. This is one of the main differences between Java and C / C in grammar. In C and C , the flexibility of the pointer will bring great convenience to the program design, but its flexibility has also become a major factor that leads to the unstable procedures. With the memory management strategy of C and C , the programmer must personally track the memory applied to the system, and finally confirm the payment to the system. And when using a pointer, you should pay attention to whether there is more than legitimate memory space, resulting in a problem such fault or General Protection Fault. Java provides a reference (Reference) type to replace pointers, by reference to accessing the application memory space, ensuring that it does not access the memory space that does not belong to, at the same time, the execution system of the program can also dynamically do memory garbage. Recycling, recover those memory spaces that are canceled to the system. This dynamic memory allocation mechanism ensures a certain degree of security in memory allocation by sacrificing certain flexibility. O No longer a function of function. In the Java programming language, the most important partial-function in the structured language is canceled. In the concept of object-oriented programming, the data of the object is a real subject, and the method of processing object data must be attached to the object. Therefore, the function concept is completely unnecessary. This enhances object-oriented development strategy. O No longer used structure, union, and typedef. In fact, in C , you can remove Structure and UNION, etc. of C , the custom structure type of complex data, because the definition of class (Class) is fully capable of doing this. The function of typedef can also be implemented by a class. Although C is designed to be compatible with C, these are excess language characteristics, and they are abandoned in the Java language. O No longer class multiple inheritance (Multiple Inheritance). In C , multiple inheritance is a strong function, but it is also difficult to master. Canceling multiple inheritance reduces the functionality of the Java language, but it makes Java look simpler. At the same time, Java also provides an interface (interface), and some of the multiple inheritance can be implemented. And multiple inheritance differences in the interface does not define content of the class method, and data in the class. O No longer operator overloading. Operator overload is seen as a feature of C .

转载请注明原文地址:https://www.9cbs.com/read-29145.html

New Post(0)