Consequently, our program will compile and link correctly.IncludeHeader
You’re probably curious why we use angled brackets for iostream, and double quotes for add.h. The answer is that angled brackets are used to tell the compiler that we are including a header file that was included with the compiler. The double-quotes tell the compiler that this is a header file we are supplying, which causes it to look for that header file in the current directory containing our source code first.
Rule: Use angled brackets to include header files that come with the compiler. Use double quotes to include any other header files.
Another commonly asked question is “why doesn’t iostream have a .h extension?”. The answer is, because iostream.h is a different header file than iostream is! To explain requires a very short history lesson.
When C++ was first created, all of the files in the standard runtime library ended in .h. Life was consistent, and it was good. The original version of cout and cin lived in iostream.h. When the language was standardized by the ANSI committee, they decided to move all of the functions in the runtime library into the std namespace (which is generally a good idea). However, this presented a problem: if they moved all the functions into the std namespace, none of the old programs would work any more!
To try to get around this issue and provide backwards compatibility for older programs, a new set of header files was introduced that use the same names but lack the .h extension. These new header files have all their functionality inside the std namespace. This way, older programs that include #include
Make sure when you include a header file from the standard library that you use the non .h version if it exists. Otherwise you will be using a deprecated version of the header that is no longer supported.
As a side note, many headers in the standard library do not have a non .h version, only a .h version. For these files, it is fine to include the .h version. Many of these libraries are backwards compatible with standard C programming, and C does not support namespaces. Consequently, the functionality of these libraries will not be accessed through the std namespace. Also, when you write your own header files, they will all have a .h extension, since you will not be putting your code in the std namespace.
Rule: use the non .h version of a library if it exists, and access the functionality through the std namespace. If the non .h version does not exist, or you are creating your own headers, use the .h version
by http://www.learncpp.com/cpp-tutorial/19-header-files/
Software Engineering.
Categories
- vb (10)
- visual basic (10)
- Glassfish (9)
- java (8)
- Software engineering (5)
- pardus (4)
- C++ (3)
- Canım İstedi (3)
- OpenSolaris (3)
- jdk (3)
- Database (2)
- Mim (2)
- BackTrack (1)
- Basit Dos Komutları (1)
- Binary Tree Traversals (1)
- Dim (1)
- Hakkımda (1)
- Java öğren (1)
- Larry Ellison (1)
- Msn (1)
- Pardus geliştircileri toplantısı (1)
- Programlama Dilleri (1)
- Ramazan Bayramı (1)
- Steve Jobs (1)
- Streaming (1)
- VritualBox (1)
- Windows (1)
- film (1)
- merkez bankası (1)
- parallel Computing (1)
- virüs (1)
- xml (1)
- yazılım mühendisliği (1)
Links
12:21
Etiketler: C++
Kaydol:
Kayıt Yorumları (Atom)
0 yorum:
Yorum Gönder