K
kalki70
Hello,
I have a doubt about this operator, and I haven't found the answer in
internet (yet).
When calling the operator << several times in an expression, are all
parameters evaluated first and then passed to cout::<<, or are being
passed when they are evaluated ?
An example to clarify my question :
int foo()
{
cout << "calling foo";
return 1;
}
......
cout << "i = " << foo() << endl;
Should I see this:
calling fooi = 1
or
i = calling foo1 ??
Or is it undefined behaviour?
So going to the original question.... is "i=" passed to cout::<< first
and then foo() is evaluated and passed to cout::<<, or is foo()
evaluated and just then "i = " and foo() are passed to cout::<< ?? Or
undefined behaviour?
Thanks in advance,
Luis
I have a doubt about this operator, and I haven't found the answer in
internet (yet).
When calling the operator << several times in an expression, are all
parameters evaluated first and then passed to cout::<<, or are being
passed when they are evaluated ?
An example to clarify my question :
int foo()
{
cout << "calling foo";
return 1;
}
......
cout << "i = " << foo() << endl;
Should I see this:
calling fooi = 1
or
i = calling foo1 ??
Or is it undefined behaviour?
So going to the original question.... is "i=" passed to cout::<< first
and then foo() is evaluated and passed to cout::<<, or is foo()
evaluated and just then "i = " and foo() are passed to cout::<< ?? Or
undefined behaviour?
Thanks in advance,
Luis