From owner-freebsd-questions@FreeBSD.ORG Fri Dec 16 16:13:07 2005 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 01AFF16A41F for ; Fri, 16 Dec 2005 16:13:07 +0000 (GMT) (envelope-from davmiao@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0EC1643D58 for ; Fri, 16 Dec 2005 16:13:05 +0000 (GMT) (envelope-from davmiao@gmail.com) Received: by zproxy.gmail.com with SMTP id 16so746405nzp for ; Fri, 16 Dec 2005 08:13:05 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=TQqVpVVbV7W+Ddl4KwIPlMKD3K5p3AC4aqkiBKsa5FaUOCJRLCNt7/AOtF4CyI4yzNsyKnXYSbyk8YTrT6l8gSCTzh1DHJYKcpfiqoX0GQpOys1aqtaRpi21sHUGgUzBywbQVCPbgp5Sx+n0T0Rrl7duspnkrJplD+hnMyvCbpo= Received: by 10.65.116.16 with SMTP id t16mr2178552qbm; Fri, 16 Dec 2005 08:13:05 -0800 (PST) Received: by 10.65.51.14 with HTTP; Fri, 16 Dec 2005 08:13:05 -0800 (PST) Message-ID: <979f20140512160813i5394e789u1d7624a625e893f@mail.gmail.com> Date: Sat, 17 Dec 2005 00:13:05 +0800 From: David Miao To: Nathan Vidican In-Reply-To: <43A2DE53.7080207@wmptl.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <979f20140512160709n3530c01dmdad5714f8e30bc00@mail.gmail.com> <43A2DE53.7080207@wmptl.com> Cc: questions@freebsd.org Subject: Re: C++ compile error X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2005 16:13:07 -0000 On 12/16/05, Nathan Vidican wrote: > David Miao wrote: > > Dear list, > > > > I try to compile a hello world C++ program in FreeBSD 6.0, but get an > > error as below: > > > > [dm@ORION ~/cpp]% CC -o hello hello.C > > hello.C: In function `int main()': > > hello.C:5: error: `cout' undeclared (first use this function) > > hello.C:5: error: (Each undeclared identifier is reported only once > > for each function it appears in.) > > hello.C:5: error: `endl' undeclared (first use this function) > > > > I noticed that "iostream" file is located in > > "/usr/include/c++/3.4/iostream", I guess my CC compiler cannot find > > this head file. Is it true? And how can I fix this problem? Your > > advice is appreciated. Thanks in advance. > > > > =3D=3Dquote of hello world code=3D=3D > > #include > > > > int main() > > { > > cout << "Hello World!" << endl; > > > > return 0; > > } > > =3D=3D end of quote=3D=3D > > > > Regards, > > David > > _______________________________________________ > > freebsd-questions@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd= .org" > > > > > > > > Also, noticed your code is flawed, you never used a namespace, nor explic= itly > stated one. cout is part of the 'std' namespace, so either ' using namesp= ace > std;' for global/local use of namespace, OR do 'std::cout <<' instead. Tr= y the > hello.cpp I sent you in the last email, that one should work for ya :) > > -- > Nathan Vidican > nvidican@wmptl.com > Windsor Match Plate & Tool Ltd. > http://www.wmptl.com/ > Nathan, I'm learning c++ programming language by using "The complete c++ training course - second edition" (Harvey Deitel & Paul Deitel), hello world is the first program in this book. I'm totally puzzled by this complex language when I compile my first program. Is this book out of date? This post may off topic of FreeBSD, sorry to other people... Regards, David