delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/26/14:35:58

From: horst DOT kraemer AT t-online DOT de (Horst Kraemer)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: cout and cin
Date: Fri, 26 Nov 1999 18:02:03 GMT
Organization: T-Online
Lines: 35
Message-ID: <383ebc9e.17891108@news.btx.dtag.de>
References: <19991126104845 DOT 16521 DOT 00000398 AT ng-fp1 DOT aol DOT com>
Mime-Version: 1.0
X-Trace: news08.btx.dtag.de 943639323 20701 0306239354-0001 991126 18:02:03
X-Complaints-To: abuse AT t-online DOT de
X-Sender: 0306239354-0001 AT t-dialin DOT net
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On 26 Nov 1999 15:48:45 GMT, cavgp AT aol DOT com (CAVGP) wrote:

> Hello there,
> 
> I am new in C++ and tried to compile a simple "hello.cc" using GCC in Delories
> DJGPP 2.95.2, and my problems are;
> 
> 1) invalid operand 'const char[23]' and 'int' to binary operation <<; the
> program
> 
>      int Add (int x,int y)
>      { 
>        cout << ("The number entered was" << x << "and" << y << "\n");

The parens are evil.

  cout << "The number entered was " << x << " and " << y << endl;

This will be parsed from left to right as it should

   ((((cout<<"The number entered was ")<<x)<<" and ")<<y)<<endl;

>        return(x+y);

'return' is not a function. Forget the parens.

          return x+y;

Although putting parens doesn't do any damage in this case. It just
serves no purpose.


Regards
Horst

- Raw text -


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