On Tuesday, January 29, 2013 4:08:02 AM UTC+1, jis wrote:
> On Monday, January 28, 2013 6:02:06 PM UTC-8, red floyd wrote:
>
> > On 1/28/2013 5:11 PM, jis wrote:
>
> >
>
> > [thread redacted
>
> >
>
> > > Sorry for the confusion.
>
> >
>
> > > Let me rephrase it again.
>
> >
>
> > >
>
> >
>
> > > 1. I have one.cpp and its header one.h
>
> >
>
> > > 2. I have two.cpp and its header two.h
>
> >
>
> > > 3. two.cpp uses a lib (three.lib). so i include three.h in two.h
>
> >
>
> > > 4. one.cpp calls functions in two.cpp. so i need to include two.h in one.h
>
> >
>
> > > but that will expose three.lib also to one.cpp.
>
> >
>
> > > I dont want this. I want top layer to access only one layer down only. not
>
> >
>
> > > all the layers below.
>
> >
>
> > >
>
> >
>
> >
>
> >
>
> > Does two's interface depend on three? That is, is there anything in
>
> >
>
> > two.h that depends on three.h? If not, then move the #include of
>
> >
>
> > three.h into two.cpp
>
> >
>
> >
>
> >
>
> > Minimum visibility and all that jazz.
>
>
>
> thanks for the replies.
>
> yes include of three.h can be moved to two.cpp
>
>
>
> but i wanted to include only two.h in the two.cpp ( as a standard way)
>
> is there any design i can implement for this?
I don't know who told you this was "standard", but they were EXTREMELY wrong.
Implementation (*.c) can use all sorts of things that are irrelevant for the public interface. To use them, it needs to #include public interface of these things.
Interface, OTOH, should expose only... Well, the interface. Anything else is a distraction and a pointless attack on encapsulation.
Goran.
|