If global variables are frowned upon, then I can say the same about static variables. They are usually all the time made public.
[Code:class myClass { public: myClass() {} static int s_x; }; int myClass::s_x = 10; int main ( void ) { std::cout << "Value of static x: " << myClass::s_x << std::endl; return 0; }
Am I wring in the assumption?
Their value is held between function calls, so is a global variables, and is not lost when the function returns. So why would you use static when global do the same thing?