Using namespace std; What is the use of [转]

xiaoxiao2021-03-06  75

Using namespace std; there is a lot of use! -------------------------------------------------- ------------ actually tells the compiler, what is your type, where can you find it. Commonly used is Using Namespace STD, that is, the standard namespace with C . You can also quote your own namespace. For example: Import "c: /mytest/test.tlb" Using Namespace CMYTEST can reference the various types of type C prime in CMYTEST --------------------- ----------------------------------------- Declare this file uses the C standard library ! For example #include using namespace std; void main () {cout << "Hello!" << endl;} If you don't need using namespace std; then std :: cout << "Hello! << This is the problem of name space! See the relevant books, the new version of C books should be introduced! -------------------------------------------------- ------------- USING indicator! This is a name space problem, which is the new concept introduced by standard C ! Specifically in the "C Primer" section 8.6, there is a detailed description! -------------------------------------------------- ------------- Because the standard library is very large, the programmer is very likely to be the same as a certain name in the standard library when the name or function name is selected. Therefore, in order to avoid the conflict of the names caused by this situation, everything in the standard library is placed in the namespace STD. But this will bring a new issue. Countless original C code relies on the functions in the multi-year counterpart library, they are under global space. So there is a header file for and , one for compatibility with the previous C code, one to support new standards. -------------------------------------------------- ------------- The name is space, essentially, for the convenience of the program to run correctly on different platforms. -------------------------------------------------- ------------- Namespace is introduced to solve the name of the name in C . What is the name conflict? For example, there is a class myclass in file x.h, and there is a class myclass in file y.h, and the X.H and Y.h files are referenced in the file z.cpp. Obviously, according to the usual method is not possible, what should I do? Introducing NameSpace.

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

New Post(0)