gcc323 and gcc332 101
Miguel Ram__rez J__vega
mramirez@iua.upf.es
Thu Jan 29 17:30:00 GMT 2004
> I cannot get it to build using #include <iostream>. I get the following
> compile time error:
>
> [langley]:/home/philc/GCC/test> g++ -o test2 test2.cpp
> test2.cpp: In function `int main()':
> test2.cpp:6: `cout' undeclared (first use this function)
> test2.cpp:6: (Each undeclared identifier is reported only once for each
> function it appears in.)
> test2.cpp:6: `endl' undeclared (first use this function)
>
>
If you include <iostream>, then cout, cin and the like are declared inside the 'std' namespace. So the right way ( using that header, which is the standard ) could be:
#include <iostream>
using std::cout;
using std::endl;
int main( int argc, char** argv )
{
cout << "Hi" << endl;
return 0;
}
or better, IMHO
#include <iostream>
int main( int argc, char** argv )
{
std::cout << "Hi" << std::endl;
}
Miguel.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20040129/e59024cb/attachment-0001.sig>
More information about the Gcc-help
mailing list