+ 2
what is the output of this code? template<class t> void f(t){ static int I=0; cout<<I++; } int main (){ f(1); f(1.0); f(1); }
5 Respuestas
+ 2
012. type doesn't matter. also use typename instead of class in the template
+ 1
If the code of function is
cout<<I++;
The answer will be 001.
If code is
cout<<++I;
Then answer will be 112.
0
geometry: i thought putting class or typename was absolutely the same, and iirc on cppreference it puts so.
0
can someone explain reason for the answer?? Also why it gets compiled even though there is no variable in the function parameters("void f(t)")??
- 4
no output as f( t ) is just declared not defined