Re: Very basic question

From: Der Andere (matieuloeschmich_at_gmx.net)
Date: 06/23/04


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



Relevant Pages

  • Re: instantiation point discussion
    ... Or buy the full compiler. ... code to a cpp file, compile it with /FAsc, and look at the resulting .cod ... Tim Roberts, timr@xxxxxxxxx ...
    (microsoft.public.vc.language)
  • Re: Full path to src in a static library
    ... Oleg Starodumov wrote: ... to the .cpp file that was passed to the compiler. ... Best Regards ...
    (microsoft.public.vc.debugger)
  • Re: GDI+ newbye
    ... I did met the same problem, after comment below lines in the cpp file is ok. ... Regards ... > I'm trying to use GDI+ in a MFC applcation, ... > The compiler tells me: ...
    (microsoft.public.vc.mfc)
  • Re: Internal Complier Error in Visual C++ 1.52
    ... You're using a very old version of both the IDE and the compiler. ... > function declaration for an existing class in a header file and function ... > implementation in the .cpp file i am getting an error as given below ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Preprocessor, nested files etc.
    ... > we have to do this, it takes around 2 hours for a complete recompile). ... > When the compiler compiles a *.cpp file, it starts in a fresh state. ... > it has learned by compiling a previous source code file remains. ...
    (comp.lang.cpp)