help, gcc, ?cout error?
Tom Barron
tbarron@mindspring.com
Sun Dec 12 09:09:00 GMT 1999
Hi, Jesse. I pasted your code into a file called jesse.cpp on my
system. Watch this:
$ gcc jesse.cpp
/tmp/ccyMXXQa.o: In function `main':
/tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout'
/tmp/ccyMXXQa.o(.text+0x2a): undefined reference to
`ostream::operator<<(int)'
collect2: ld returned 1 exit status
$ g++ jesse.cpp
$ a.out
5$
The problem is that cout and iostream.h are part of C++, but gcc only
handles C. To compile C++ code, you need to invoke the compiler as g++.
To get a newline on the end of your output, you might want to do
cout << a << endl;
hth...
Tom
aka007@mail.com wrote:
>
> i modified it a bit, here is the current version:
>
> UW PICO(tm) 2.9 File: a.cpp
> ...
More information about the Gcc-help
mailing list