If the library is included in the class header and then this header is included in another class, do I need to include the library again?
For instance:
#ifndef A_H #define A_H #include<someLibrary.h> class A{ ... } #endif
Then another class includes the heading Ah
#include<A.h> //include class A class B{ ... }
Do I need to include "someLibrary.h" in class B?
No, they #includeare transitive.
#include
, someLibrary, . , " ", . , #include , . .
, , ( , ).
C/++ GNU cpp.
foo.cc, . g++ -Wall -C -E foo.cc ( )
foo.cc
g++ -Wall -C -E foo.cc
(, 200KLOC), , , ( , , ). BTW, ( ) . #include -d .
, ++ (, <map> <vector>....) , ( Linux #include <vector> , )
<map>
<vector>
#include <vector>
, ++ - ( ). , ++ .
( , )
preprocessor #include , , .
: , , a.h
a.h
// Our class class A { // Stuff for the class }; // End of the class
a.cpp:
a.cpp
// Include header file #include "a.h" // Header file included int main() { // Code }
,
// Include header file // Our class class A { // Stuff for the class }; // End of the class // Header file included int main() { // Code }
, , , .
, , , , .
, . ( ) , . ( ) , , .
, -, .