On Thu, 2002-10-17 at 17:10, Aly Dharshi wrote:
> #include <iostream>
> 
> int main()
> {
>         cout << "Testing 1 2 3 ... \n";
>         return 0;
> }
> 
> 
> Tried compiling this simple program and can't understand why the error,
> system produces the following errors:
> 
> test_cc1.cc: In function `int main()':
> test_cc1.cc:5: `cout' undeclared (first use this function)
> test_cc1.cc:5: (Each undeclared identifier is reported only once for
> each
>    function it appears in.)
> 
>       Any suggestions as to why this maybe ?

Not a problem with GCC. Your code is incorrect. GCC 3.2 in RH 8.0 is
more standards compliant then any version released by Red Hat before.
Incorrect code that compiled before will not now.

Two ways to fix it.

#include <iostream>
using namespace std;

int main()
{
        cout << "Testing 1 2 3 ... \n";
        return 0;
}

or

#include <iostream>

int main()
{
        std:cout << "Testing 1 2 3 ... \n";
        return 0;
}

Grab your C++ book and read the chapter on namespaces.

Regards,
        Jim H



-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@;redhat.com?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to