cout << a.get(); << b.get(); << c.get(); << endl
cout << a.get() << ' ' b.get() << ' ' c.get() ' ' << d.get() << endl;
error: expected `;' before 'b' |
std::cout << a.get() << " " << b.get() << std::endl;
(what a.get() returns)<space>(what b.get() returns) |
cout << a.get() << " "<< b.get() << " "<<c.get()<< " "<< d.get() << endl;
You can use them in a single cout but the one at the rightmost is called first. I pushed 1,2,3,4 in the stack. If I pop them and cout like this: cout<<mystack.pop(); cout<<mystack.pop(); cout<<mystack.pop(); cout<<mystack.pop(); output order is : 4,3,2,1. But if I pop them in a single cout: cout<<mystack.pop()<<" "<<mystack.pop()<<" "<<mystack.pop()<<" "<<mystack.pop(); The output is : 1 2 3 4 |
What? I am pretty sure that shouldn't be the case... are you sure this is what happens? |
I'm 100% certain that operations are evaluated left-to-right. It has to. |
|
|
13 12 11 Now call in a single cout: 11 12 13 |
|
|
3 1 |
i++
seems to have been evaluated first.
std::cout << ++i << ' ' << i++;
is still bad since you are modifying i twice in the same expression ( and the result of that is undefined according to the C++ standard )