Mail Archives: djgpp/1999/11/26/14:35:58
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 -