"saneman" <as***@asd.comwrites:
I have made two modules:
Good.
1) main.cpp
2) head.h
Wrong.
If you have two modules, you should have five files:
interface implementation
Module A: ModuleA.h ModuleA.cpp
Module B: ModuleB.h ModuleB.cpp
Main: main.cpp
Assuming ModuleB uses ModuleA, and main uses both modules, you will have:
------(ModuleA.h)-----------------------
#ifndef ModuleA_h
#define ModuleA_h
// public definitions of module A
#endif
----------------------------------------
------(ModuleA.cpp)---------------------
#include <ModuleA.h>
// implementation of module A
----------------------------------------
------(ModuleB.h)-----------------------
#ifndef ModuleB_h
#define ModuleB_h
#include <ModuleA.h>
// public definitions of module B
#endif
----------------------------------------
------(ModuleB.cpp)---------------------
#include <ModuleB.h>
// implementation of module B
----------------------------------------
------(main.cpp)------------------------
#include <ModuleA.h>
#include <ModuleB.h>
// implementation of main:
int main(int argc,char** argv,char** envv){
ModuleA::doSomething();
ModuleB::doSomething();
return(0);
}
----------------------------------------
Note that you cannot have cross dependencies between the interfaces of
the modules, but you may have cross dependencies between
implementations and interfaces:
ModuleC.cpp could include ModuleD.h
and ModuleD.cpp could include ModuleC.h
this would mean that both modules C and D are at the same layer.
Otherwise the dependencies between the modules correspond to the
layers structuring the software.
--
__Pascal Bourguignon__