Suggestions for C programmers for (learning C ++)

zhaozj2021-02-17  50

From C Programming Language 1.6.1 Relationships, please advise

Recommendation for C programmers

The more familiar with C, the more it is, the harder C programs that write C mode. Therefore, some of the advantages of some potential C will be lost. Please see Appendix B, which describes the difference between C and C . There are a few points here to use the C mode program compared to the C program. 1. Macro never need to use const or enum to define static variables in C , use inline to avoid function call overhead, template to point out functions and types, Namespace avoid naming conflicts. 2. Don't declare it before using a variable (translator, don't declare in advance, when do you declare, and initialize immediately). It should be in any place (translator, compared to C), including in the context of for and IF. 3. Don't use malloc (), New operator to do the same thing, and do better. Instead of Realloc (), you can try the vector. 4. Try to avoid the VOID *, Pointer Alithmetic, Union (Union) and Model (CAST is a type conversion). In most cases, the model is the performance of the wrong design. If you have to force type conversion, try "New Casts" because it makes you do more accurate. 5. Reduce the character arrays in C mode, the C standard class library provides String and Vector classes to simplify the program (comparison with traditional C mode), in general, do not write a program that exists in the standard library. In order to adapt to the C-connection custom, the C function must declare to C-join mode. Most importantly, try to view a program as an interaction concept (translator: member and method ??), and display a bunch of data structures that are operated instead of function manipulation.

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

New Post(0)