+ 1
The output for this code is 11. Can anybody explain the reason
template class<T> void f(T){ int i= 0; cout<<++i; } int main() { f(2); f(4.2); }
6 Answers
+ 15
the output should be 11 because you can see i is always initialised with 0,so the function f will always output 1 irrespective of the passed parameter.
+ 14
it should be 11,why will the output be in different lines as no \n or endl is used.
+ 2
cout doesn't add endline by itself, you have to explicitly specify it.
cout << ++i <<endl;
+ 2
i will be initialized to 0 each time function will be called so thats two times 1
gets printed
and as no endl or /n therefore no new line .......isnt it simple
0
ohkay..so it must be
1
1
and not "11" !
I got confused with this
0
f() is called twice ..so I think it should be in different lines