From owner-freebsd-questions@FreeBSD.ORG Wed Jan 4 12:11:58 2006 Return-Path: X-Original-To: freebsd-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 22D4B16A41F for ; Wed, 4 Jan 2006 12:11:58 +0000 (GMT) (envelope-from freebsd-questions@m.gmane.org) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 001DE43D46 for ; Wed, 4 Jan 2006 12:11:55 +0000 (GMT) (envelope-from freebsd-questions@m.gmane.org) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Eu7UV-0004nw-6X for freebsd-questions@freebsd.org; Wed, 04 Jan 2006 13:11:43 +0100 Received: from c-24-147-87-49.hsd1.ma.comcast.net ([24.147.87.49]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 04 Jan 2006 13:11:43 +0100 Received: from jdarnold by c-24-147-87-49.hsd1.ma.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 04 Jan 2006 13:11:43 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-questions@freebsd.org From: Jonathan Arnold Date: Wed, 04 Jan 2006 07:11:32 -0500 Lines: 73 Message-ID: References: <979f20140512160709n3530c01dmdad5714f8e30bc00@mail.gmail.com> <43A2DE53.7080207@wmptl.com> <979f20140512160813i5394e789u1d7624a625e893f@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: c-24-147-87-49.hsd1.ma.comcast.net User-Agent: Thunderbird 1.5 (Windows/20051201) In-Reply-To: <979f20140512160813i5394e789u1d7624a625e893f@mail.gmail.com> Sender: news 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: Wed, 04 Jan 2006 12:11:58 -0000 David Miao wrote: > 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. >>> >>> ==quote of hello world code== >>> #include >>> >>> int main() >>> { >>> cout << "Hello World!" << endl; >>> >>> return 0; >>> } >>> == end of quote== >>> >>> 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 explicitly >> stated one. cout is part of the 'std' namespace, so either ' using namespace >> std;' for global/local use of namespace, OR do 'std::cout <<' instead. Try 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? No, Deitel and Deitel isn't too bad. If you are new to programming in general, I highly recommned "C++ : A Dialog", by Steve Heller. He gradually takes someone along to learn programming with C++. In fact, the full text is available on his web site: http://www.steveheller.com/cppad/Output/dialogTOC.html -- Jonathan Arnold (mailto:jdarnold@buddydog.org) Daemon Dancing in the Dark, a FreeBSD weblog: http://freebsd.amazingdev.com/blog/ UNIX is user-friendly. It's just a bit picky about who its friends are.