Re: newbie question
- From: "Tom Serface" <tserface@xxxxxxx>
- Date: Mon, 27 Mar 2006 15:57:19 -0800
You need to do the include anywhere you want to reference the variable, but
if you want to use the same variable in another file then put an "extern" in
front of the declaration so the compiler knows it's created elsewhere.
Othewise you will end up with two variables with the same name.
Tom
"Mark1110" <Mark1110@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F11815BD-0A3F-426D-B0B7-85B3901395DE@xxxxxxxxxxxxxxxx
Hi,
I am relativly new to VC++. I have a source file called complx.cpp.
Because
I want to print to a text file, I have the following statements in the
.cpp
file:
# include <fstream.h>
ofstream echo("c:\\output.txt", ios::app);
I also have another file called funct.cpp which has member functions in
it.
For some reason I can't compile it unless I use the above statements in
the
source. When I try an link the files I get an error message saying echo is
already defined in complx.obj. I have been racking my brains trying to
figure
out a way to make it work. Can someone tell me what I need to do to make
it
link correctly. Both .cpp files are in my project.
Thanks,
Mark
.
- Prev by Date: Re: VC++ 6 / VC++2003 / VC++2005 in same machine.
- Next by Date: console output in debug window of visual studio
- Previous by thread: first time: run Qt under Visual Studio
- Next by thread: console output in debug window of visual studio
- Index(es):
Relevant Pages
|