Mega Code Archive

 
Categories / C++ / Language
 

Static Member Functions

#include <iostream> using namespace std; class static_type {   static int i; public:   static void init(int x) {      i = x;   }   void show() {      cout << i;   } }; int static_type::i; int main() {      static_type::init(100);   // init static data before object creation   static_type x;   x.show();    return 0; }