public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Young, Michael" <Michael.Young@paetec.com>
To: <jjdevine@adelphia.net>, 	<gcc-help@gcc.gnu.org>
Subject: RE: GCC Compile Failure
Date: Mon, 10 Jul 2006 14:55:00 -0000	[thread overview]
Message-ID: <BD32241188571B4CBD35DC95FD791C7FFBD414@mail1-corp.corp.paetec.com> (raw)
In-Reply-To: <200607081320.49645.jjdevine@adelphia.net>

Welcome to C++!
I know this is a gcc maillist and not one for C++ specifically, but I'm going to clarify things using the C++ standard.  I highly recommend you get a copy of this and get used to referencing it - it's heady stuff, and overwhelming at first (and for some time afterward), but it is the standard and can steer you clear of a LOT of "well-intentioned-but-bad" advice available on the web and in forums.  To help you sort through things from a practitioner's (rather than "language lawyer") perspective, there are a few good references - I use C++ Primer (now in 4th ed., by Lippman, Lajoie, and Moo) most often.

As was previously pointed out, cout is an object, not a function.  You need to "#include <iostream>" to pick up the definition - see C++ Std - 27.3.  As was also pointed out, C++ std library include files don't have an extension (officially, again, certain implementations continue to support legacy, non-standard extensions).  (C++ Std. 17.4.1.2)

In addition, although it will work with "#include <stdio.h>", I'd recommend using "#include <cstdio>" and change the printf to std::printf.  (Or simply declare "using namespace::std;" and drop all the "std::" prefixes.  When you get a chance, you may want to look at "namespaces" in a good C++ reference.
See appendix D - D.5 in the C++ std and section 17.4.1.2 for details.

Finally, as a good programming practice, do not rely on the "implicit int return" - declare main as "int main( )".  BTW - you may see a lot of examples out there with different prototypes/signatures for main - there are only two "official" signatures for this function (and "int main( )" is one of them) - see C++ Std - 3.6.1 paragraph 2.

  parent reply	other threads:[~2006-07-10 14:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-08 20:18 jjdevine
2006-07-08 21:06 ` Artūras Moskvinas
2006-07-10 14:55 ` Young, Michael [this message]
2006-07-09  1:06 Bill McEnaney
2006-07-09  1:24 Bill McEnaney
2006-07-09  1:55 ` Brian Dessent
2006-07-09  2:00 ` David Fang
2006-07-09  2:35 Bill McEnaney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BD32241188571B4CBD35DC95FD791C7FFBD414@mail1-corp.corp.paetec.com \
    --to=michael.young@paetec.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=jjdevine@adelphia.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).