Re: gcc323 and gcc332 101

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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.

Attachment: pgp00014.pgp
Description: PGP signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux