delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/06/28/12:45:39

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3EFDC620.8060402@t-online.de>
Date: Sat, 28 Jun 2003 18:45:20 +0200
From: =?ISO-8859-1?Q?Markus_Sch=F6nhaber?= <mks99 AT t-online DOT de>
Reply-To: cygwin AT cygwin DOT com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624
X-Accept-Language: de-de, de, en-us, en
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: g++ error
References: <LAW15-DAV71nkrS4mWG0001e592 AT hotmail DOT com>
In-Reply-To: <LAW15-DAV71nkrS4mWG0001e592@hotmail.com>

Peng Yu wrote:
> Hi,
>     When I tried to compile this file by g++, I got a error.
> 
> #include <iostream>
> int main(){
> cout << "Hello World" << endl;
> }
> 
> errors are:
> 
> test.C: In function `int main()':
> test.C:3: `cout' undeclared (first use this function)
> test.C:3: (Each undeclared identifier is reported only once for each
> function
>    it appears in.)
> test.C:3: `endl' undeclared (first use this function)
> 
> Do I need to install some library?

No, you simply have to respect C++ namespaces. Try

std::cout << ... << std:endl;

or alternatively

#include <iostream>
using namespace std;
...

Regards
   mks


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019