Re: Very basic question
From: Der Andere (matieuloeschmich_at_gmx.net)
Date: 06/23/04
- Next message: Richard Herring: "Re: creating methods for objects"
- Previous message: Thomas Matthews: "Re: speed it up"
- In reply to: John Harrison: "Re: Very basic question"
- Next in thread: John Harrison: "Re: Very basic question"
- Reply: John Harrison: "Re: Very basic question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 23 Jun 2004 16:13:37 +0200
> > Say I have a project containing four files: a.cpp, a.h, b.cpp and b.h,
> where
> > a.h is included in a.cpp and b.h is included in b.cpp.
> > Can I make cross-references from a to b. For instance, can I use a class
> > defined in b.cpp in a.cpp?
>
> Yes, of course, it would be very hard to write programs in seperate files
> without that facility.
>
> > Or do I have to add '#include "b.cpp" ' into
> > a.cpp?
> >
>
> No that would be a bad idea. Most likely you need to ' #include "b.h" ' in
> a.cpp.
Yes, indeed that causes less problems.
> But maybe your problem is with something else entirely, why not post the
> code?
It is more than a few hundred lines. I developed the two files independently
from each other but now they need to interact. Whenever I tried to include
one cpp file within the other I got lots of errors because I used the same
libraries in both cpp files.
I did not have the idea myself to include only the headers. I thought this
would not work because there is no reference to b.cpp if I include b.h
within a.cpp. Does it work because b.cpp is in my project as well? Or does
the compiler *guess* that there must be a b.cpp if there is a b.h?
However, it works fine now, thanks!!
Regards,
Matthias
- Next message: Richard Herring: "Re: creating methods for objects"
- Previous message: Thomas Matthews: "Re: speed it up"
- In reply to: John Harrison: "Re: Very basic question"
- Next in thread: John Harrison: "Re: Very basic question"
- Reply: John Harrison: "Re: Very basic question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|