what is the different between all the include types ?

hello all
im confuse here there is several include types and i dont understand why for example
in the c++ file i can see :


or

or
"somefile.h"

what is the difference between them ?

also what is the difference if for example i but the include file im using in the header file and then i include the header file
in the c++ file or just put the include files in the cpp file ?

thanks

Comments

  • In traditional C, there is for library files that come with the compiler, and "somefile.h" for user-created header files.

    When C++ was first made, it used the same syntax to remain compatible with C. In later C++ standards, they got rid of the .h for the library files, because they predicted that the operative systems of the future wouldn't have file extensions. After they did that, C++ was no longer code-compatible with C.

    The correct syntax in standard C++ is therefore for library files and "somefile.h" for user-created headers. If the compiler allows it does not follow the standard.


    : also what is the difference if for example i but the include file im
    : using in the header file and then i include the header file
    : in the c++ file or just put the include files in the cpp file ?

    There is no difference, apart from style. It is common that all includes are placed in the h-file, but it it perhaps a bit cleaner to put them in the cpp file. It is just a matter of taste, really.
  • : In traditional C, there is for library files that come
    : with the compiler, and "somefile.h" for user-created header files.
    :
    : When C++ was first made, it used the same syntax to remain
    : compatible with C. In later C++ standards, they got rid of the .h
    : for the library files, because they predicted that the operative
    : systems of the future wouldn't have file extensions. After they did
    : that, C++ was no longer code-compatible with C.
    :
    : The correct syntax in standard C++ is therefore for
    : library files and "somefile.h" for user-created headers. If the
    : compiler allows it does not follow the standard.
    :
    :
    : : also what is the difference if for example i but the include file im
    : : using in the header file and then i include the header file
    : : in the c++ file or just put the include files in the cpp file ?
    :
    : There is no difference, apart from style. It is common that all
    : includes are placed in the h-file, but it it perhaps a bit cleaner
    : to put them in the cpp file. It is just a matter of taste, really.

    In addition to that remember that one in quotes, "", and not <> usually refer to a file somewhere local to the source file you are writing and not the library path or what ever you wish to call it.
  • : : In traditional C, there is for library files that come
    : : with the compiler, and "somefile.h" for user-created header files.
    : :
    : : When C++ was first made, it used the same syntax to remain
    : : compatible with C. In later C++ standards, they got rid of the .h
    : : for the library files, because they predicted that the operative
    : : systems of the future wouldn't have file extensions. After they did
    : : that, C++ was no longer code-compatible with C.
    : :
    : : The correct syntax in standard C++ is therefore for
    : : library files and "somefile.h" for user-created headers. If the
    : : compiler allows it does not follow the standard.
    : :
    : :
    : : : also what is the difference if for example i but the include file im
    : : : using in the header file and then i include the header file
    : : : in the c++ file or just put the include files in the cpp file ?
    : :
    : : There is no difference, apart from style. It is common that all
    : : includes are placed in the h-file, but it it perhaps a bit cleaner
    : : to put them in the cpp file. It is just a matter of taste, really.
    :
    : In addition to that remember that one in quotes, "", and not <>
    : usually refer to a file somewhere local to the source file you are
    : writing and not the library path or what ever you wish to call it.

    i) #include

    This method of inclusion tells the preprocessor to look for the file in the predefined default location. This predefined default location is often a variable that denotes the path to your include files. If the file is still not found, the preprocessor checks the current directory.

    The #include method of file inclusion is often used to include standard headers such as stdio.h or stdlib.h.



    ii) #include
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories