On Thu, 25 Nov 2004, Nicholas Tomlin wrote:

   int x = 5;
   int y = 7;
   cout << x + y " " x * y;
   cout << "\n";

xycout.cpp:7: error: syntax error before string constant

You need an operator between each, specifically the stream insertion (left shift) one.
And you can do the newline a bit neater too.


  cout << x + y << " " << x*y << endl;

I also lean towards having parenteses around the little (x+y) expressions (why make people guess?). I asked google about "c++ operators stream shift" and it gave some links that you may want to read fyi.

Here are some references I find handy or have had recommended (I particularly like the first one, and frequently refer to the first 2):

http://www.icce.rug.nl/documents/cplusplus/
http://www.sgi.com/tech/stl/
http://www.cppreference.com/
http://anubis.dkuug.dk/jtc1/sc22/open/n2356/

http://www.yrl.co.uk/~phil/stl/stl.htmlx
http://www.xraylith.wisc.edu/~khan/software/stl/STL.newbie.html
http://www.parashift.com/c++-faq-lite/

Cheers,

 - Simon
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to