Re: GCC compiler in Red Hat 9

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

 



Hello Hasan,

I see several problems:

1. <iostream.h> is not part of standard C++. The 1998 C++ standard uses <iostream> (no ".h")

2. Both <iostream> and <string> are in the "std" namespace. To use anything in the standard namespace, you need to append "std::" before the function you are using (example std::cout instead of just cout)

Try:
---------------------------------------------------

#include <iostream>
int main()
{
std::cout << "hello world";
return EXIT_SUCCESS;
}
---------------------------------------------------


P.S.: The same with endl, goes to std::endl

Regards,
   Heiko

Hasan Shibly wrote:

Hello,

I have just installed Red Hat 9 (Fresh installation on a dual boot
system with Win XP) on my system.

For some reason g++ compiler is giving me errors, even for the simple
"Hello world" program.

#include <iostream>
int main()
{
cout << "hello world";
return EXIT_SUCCESS;
}

Below is the compilation error I am facing.

$ g++ test.cpp

test.cpp:5: 'cout' undeclared (first use this function)
test.cpp:5: (Each undeclared identifier is reported only once for each
function it appears in.)

Your help is highly appreciated.

Regards
H@z@n




[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