Predict the output?
x = 1 count = 0 x = 1 count = 1 x = 1.1 count = 0
x = 1 count = 0 x = 1 count = 0 x = 1.1 count = 0
x = 1 count = 0 x = 1 count = 1 x = 1.1 count = 2
(D) Compiler Error
Explanation: Compiler creates a new instance of a template function for every data type. So compiler creates two functions in the above example, one for int and other for double. Every instance has its own copy of static variable. The int instance of function is called twice, so count is incremented for the second call.
Quiz of this Question