PHP Code:
#include <iostream>
#include <string>
using namespace std;
class test {
public:
// cannot initialize static variable in constructor
static void print (){ // service function to print static variable
cout<< a << endl;
}
static void set (int value){ // service function to set value into static variable
a = value;
}
private:
static int a; // dclaration of static variable. No initialization
};
int test::a = 0; // initialize static variable in class test
int main (){
//////////// NO OBJECTS OF TYPE test
test::print(); // the service function print the STATIC variable a
test::set(10); // the service function set the variable a without objects
test::print(); // the service function reprint the changed static variable a
return 0;
}