A brief description of the harmonious C ++ code

Source: Internet
Author: User

Visual C ++ 6.0 is a C ++ code development tool launched by Microsoft. It is the most widely used development tool. This section describes the development environment and development process of Visual C ++ 6.0. After reading this article, you will surely have a lot of GAINS. I hope this article will teach you more.

Suffix. h header file C ++ standards have been explicitly proposed not to support, earlier implementation of the standard library function defined in the global space, declared in the. in the header file with the suffix h, the c ++ standard is used to distinguish it from C, and to correctly use the namespace, it is required that the header file does not use the suffix. h.

Therefore, when you use It is equivalent to calling the library function in c and using a global namespace, that is, the early c ++ implementation. The header file does not have a global namespace. You must use namespace std; To use cout correctly.

  • Explanation of various Error Methods for C ++ Unit Testing
  • How to better and more conveniently conduct the C ++ test Program
  • List the compiling environments supported by the C ++ Compiler
  • I will introduce you to the C ++ programming Portal
  • How C ++ compiler can handle exceptions

Generally, the old C ++ code includes ". h. h. There is a ". h. Apart from many improvements made by the latter, the difference is that the latter's stuff is inserted into the std namespace.

The problem is that C ++ must be compatible with C's standard library, and C's standard library also happens to have a name called "string. h "header file, contains some common C string processing functions, such as the strcmp mentioned by the landlord.
This header file has no relationship with the string class of C ++ either, so Not "Upgrade version", they are irrelevant two header files.

For example:

 
 
  1. Void func (){
  2.  
  3. Using namespace alex; // using command
  4.  
  5. Using chris: love; // uisng statement
  6.  
  7. Love (); // chirs: love ();
  8.  
  9. Alex: love (); // This is required
  10.  
  11. }

Because the standard library is very large, the programmer may have the same name as a standard library when selecting the class name or function name. To avoid name conflicts caused by this situation, everything in the standard library is put in the namespace std. However, this poses a new problem. Countless original C ++ Code relies on features in the pseudo-standard library that have been used for many years. They are all in the global space.

So there is. And And so on. One is to be compatible with the previous C ++ code, and the other is to support new standards. All the signs in the C ++ standard library are defined in a namespace std, and iostream is also the header file in the standard library. Check the include directory and you will find two more header files, iostream. h and iostream, where iostream. h is the original library of C ++, and iostream is the Library of std in The namespace. Therefore, there are two methods when you include the header file and want to use the flag in the header file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.