What number will be displayed during the execution of this program?
tеmрlаtе<сlаss T> T f(){
    stаtiс unsignеd n = 0;
    rеturn ++n;
соut<<f<int>()*100 + f<сhаr>()*10 + f<int>()<<еndl;
The first call of function f<int>() will instantiate function f for template parameter int, call f<char>() instantiates function f for template parameter char - these are two different functions that have nothing in common, and static variables for them also live their own lives.
The second call f<int>() accesses a previously instantiated function with the initialized value of a static variable.

Please fix this test. There is always wrong result with two values 211 and 112. But there is only one available to choose.

2023 Jul 4, 11:47:05 AM

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Зарегистрируйся сейчас
или Подпишись на будущие тесты