By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,406 Members | 888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,406 IT Pros & Developers. It's quick & easy.

on cout,

P: n/a
Why cout << "Test: " << foobar() << endl;

calls foobar first? It seems:

cout.operator<<("Test: ").operator<<(foobar()).operator(endl);

would mean "Test: " is output first.

Nov 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
vsgdp wrote:
Why cout << "Test: " << foobar() << endl;

calls foobar first? It seems:

cout.operator<<("Test: ").operator<<(foobar()).operator(endl);

would mean "Test: " is output first.
If you want order then put them in separate statements:

cout << "Test: ";
cout << foobar();
cout << endl;

A chained operation like the one you posted only guarantees that the
outputs are in order. The order of evaluation of subexpressions is up to
the compiler.

Ben
Nov 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.