Re: System-header, header-file, using and ::

From: Ulrich Eckhardt (doomster_at_knuut.de)
Date: 06/26/04


Date: Sat, 26 Jun 2004 09:27:27 +0200

Edo wrote:
> Ok, it needs to be explained to me again. Even after reading I am trying
> to do what if, so whats the safe practice with the least redundancy.
>
> #ifndef GUARD_grade_h
> #define GUARD_grade_h
> //grade.h
> #include <iostream>
> #include <vector>
>
> // no using here. Only std::
> fun prototype
> #endif
>
> ///////////////////////////////////////////////////
> //grade.cpp needs iostream and vector to run
> #include grade.h
> // since grade.h has the system headers iostream and vector
> // I don’t need to include them here too, right???

Yes. The first stage when compiling is that the preprocessor scans the
given file(usually that would be grade.cpp here) and replaces all #include
statements with the content of the file being included.

> //some_other.cpp needs iostream and vector to run
> if I
> #include grade.h which needs to be in here any way then
> I don’t need to include system headers iostream and vector?

Again, the same method is applied. The fact that grade.cpp and grade.h have
the same name(except extension) is irrelevant to the compiler, it treats
some_other.cpp jush the same.

Uli

-- 
FAQ: http://ma.rtij.nl/acllc-c++.FAQ.html


Relevant Pages

  • System-header, header-file, using and ::
    ... Even after reading I am trying ... so whats the safe practice with the least redundancy. ... I don’t need to include system headers iostream and vector? ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Using Classes -- CLARIFICATIONS
    ... I didn't just simplify the code for reading here...I commented out all ... it shouldn't impact the compiling. ... > stack myStack; ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Using Classes -- CLARIFICATIONS
    ... I didn't just simplify the code for reading here...I commented out all ... it shouldn't impact the compiling. ... > stack myStack; ...
    (comp.lang.cpp)
  • RE: weird I/O problem with g77
    ... >I have come across a very strange problem whilst compiling a ... >The g77 compiler on both Cygwin and RH Linux systems produced the ... the ascii control character for linefeed) is taken as the ... it is not used in the value you are reading. ...
    (comp.lang.fortran)
  • AMDIST VAX Fortran and Intel Compiler
    ... properly compiling my FCC Fortran programs. ... Take a look at my AMDIST.FOR source code that I posted to the list ... I compiled the program with F77 compatibility, ... BTW when the program WAS reading the file initially, ...
    (comp.lang.fortran)