C ++ misunderstanding

xiaoxiao2021-04-03  209

1. Although C is mainly a new language developed in C, she is not a replacement of C, not C, C and C are brothers. No one is more advanced, more importantly, the C and C respective standard committees are independent, the latest C standard is C 98, the latest C standard is C99. Therefore, there is no first learning C to say C , no longer (note that this "no longer") has a C syntax is a super-collection of C grammar. 2. C / CLI and C # are Microsoft, they have no relationship with C and C , although some grammar is similar. But which two languages ​​are not similar? It is ABC 26 letters. 3. Do not use the ancient compilers such as TC / TC / BC / CB to learn C / C , because they are too old, do not support new C / C standards. Do not use CBX / VC 6.0 / VC2005 to support the compiler for C / C standards, although these compilers are suitable for work, but not suitable for learning because there are many grammar traps in them. Remember that the only compiler that is suitable for learning is GCC / MingW. [Antigloss Note: The compiler used by DEV-C is GCC & G ] 4. Don't use "" instead <> to include system header files, although some compilers allow you to do this, but it does not meet C / C standards. Error example: #include "stdio.h", # include "iostream". [Antigloss Note: <> is used to include the standard header file and system header file, "" is used to include custom header files. Standards do not have clearly defined "" "" "" "" "contains standard header files and system header files. Use "" "Contains the standard header file or the system header file can only be said to be a poor style. ] 5. Do not define the return type of the main function as Void, although some compilers allow you to do this, but it does not comply with the C / C standard. Do not omit the INT return type of the function, ask the compiler to give at least a warning in C . Error example: void main () {}, main () {} [Antigloss Note: C99 and C 98 require compiler to at least one warning for omitting INT] 6. Do not put the #include "stdafx in VC . h "Post it, it is a pre-translated header. Don't put the chef in the tray when you go. 7. [C ] Don't #include , don't #include because they have been explicitly discarded by the C standard, please change to #include and #include . The rule is: a. If this header file is old C unique, then remove the .h suffix, and put it in the STD namespace, such as iostream.h to Iostream. B. If this header file is C, then remove the .h suffix, add a C prefix, such as string.h to CString; stdio.h changes to CSTDIO, and so on.

BTW: Do not confuse the string, cstring, string.h three header files: Windows.h is not a standard file of C / C , so its name C / C regardless of. 8. Don't write the char * p = "xxx" statement, you have to write into const char * p = "xxx", the compiler makes the former to compile the previous large amount of old code. BTW: const type * p and Type const * p are the same, the style is different. There is also a Const keyword in the BTW: C language. 9. Do not include multiple / - of a variable in the same statement, because they are not specified in the C / C standard, depending on the personal behavior of the compiler. 10. C / C is a platform-independent language, so the system-related Process / GUI is not in the standard C / C library. For example, graphics.h and windows.h are provided by a compiler, not by C / C . 11. C / C is just a language, and it is a platform-independent language. Some people in the forum even think that C is DOS, C is Windows, then what is Linux? 12. [C ] Object-oriented is the main purpose of design C with Class (C former), but C is not, C is a multi-model language. Main support process calls, object-oriented, preferences, extensive programming, these four programming models. Of course, Functional, Generative, Metaprogramming is also supported. 13. Language is not a literary person, so when you learn a computer language, you also need to learn the data organization and algorithm, and you need to master the usage of tools and platform APIs. 14. C / C is a general language, so the syntax is complicated, you should cut into a syntax collection that suits your own, such as cutting into Better C and ADT. 15. C / C is a general language, so only universal libraries, you should enrich your own library, such as the Automotive Industry Association has its own C / C function / class / template library. This article is collected online, and its copyright belongs to the original author and the original place. If you have copyright infringement, please contact me, I will handle it immediately.

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

New Post(0)