0

What is the static variable?

14th Feb 2017, 10:03 PM
AlfinHerd
AlfinHerd - avatar
3 Réponses
+ 2
A static variable is a variable that is common to every call of the function, for example : int f(){ static int count=0; return ++count; } int main(){ std::cout<<f()<<std::endl; std::cout<<f()<<std::endl; return 0; } the result will be 1 2
14th Feb 2017, 11:39 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
thanks broo.
18th Feb 2017, 3:39 AM
AlfinHerd
AlfinHerd - avatar
0
your welcome :)
18th Feb 2017, 8:40 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar